class Autosftp::CLI
Public Instance Methods
delete(word)
click to toggle source
# File lib/autosftp/cli.rb, line 78 def delete(word) Autosftp::FileAccess.delete word end
init()
click to toggle source
# File lib/autosftp/cli.rb, line 97 def init init_file = Autosftp::FileAccess if true == init_file.exist? if yes? "File exists. Overwrite the file? [y/n]" init_file.create puts 'overwite!!! (' + init_file.path + ')' else puts 'cancel' end else init_file.create puts 'create!!! (' + init_file.path + ')' end end
list()
click to toggle source
# File lib/autosftp/cli.rb, line 83 def list() Autosftp::FileAccess.read.each do |key, value| puts <<"EOS" #{key}: host: #{value[:host]} local_path: #{value[:local_path]} remote_path: #{value[:remote_path]} EOS end end
set(word)
click to toggle source
# File lib/autosftp/cli.rb, line 45 def set(word) ssh_hash = {} begin puts "[username@host:port]" ssh_str = STDIN.gets.chomp if false == Autosftp::Connection.check?(ssh_str) puts "is not [username@host:port]" exit end ssh_hash = Autosftp::Connection.explode ssh_str puts "password:" ssh_hash[:password] = STDIN.noecho(&:gets).chomp puts "remote path:" ssh_hash[:remote_path] = STDIN.gets.chomp puts "local path: --If you enter a blank, the current directory is set" ssh_hash[:local_path] = STDIN.gets.chomp if '' == ssh_hash[:local_path] ssh_hash[:local_path] = Dir.pwd puts ssh_hash[:local_path] end Autosftp::FileAccess.save word, ssh_hash rescue Interrupt end end
start(*word)
click to toggle source
# File lib/autosftp/cli.rb, line 11 def start(*word) if false == Autosftp::FileAccess.exist? puts "is not .autosftp \n $ autosftp init" exit end conf = Autosftp::FileAccess.read if !conf[word[0]] puts "is not setting \n $ autosftp set [remote name]" exit elsif setting = conf[word[0]] word.delete_at(0) end if 0 < word.size dir = word.map {|a| a.to_s + "**/*"} else dir = '**/*' end permission = {} if options[:chmod] permission[:dir] = options[:chmod] permission[:file] = options[:chmod] else permission[:dir] = 755 permission[:file] = 644 end Autosftp::Monitor.start setting, dir, permission end