Class: Monster::Remote::CLI
- Inherits:
-
Object
- Object
- Monster::Remote::CLI
- Defined in:
- lib/monster/remote/cli.rb
Instance Method Summary collapse
-
#initialize(syncer = Sync, out = STDOUT, input = STDIN) ⇒ CLI
constructor
A new instance of CLI.
- #run(args = ARGV) ⇒ Object
- #show_version ⇒ Object
- #wait_for_password ⇒ Object
Constructor Details
#initialize(syncer = Sync, out = STDOUT, input = STDIN) ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 12 |
# File 'lib/monster/remote/cli.rb', line 8 def initialize(syncer=Sync, out=STDOUT, input=STDIN) @syncer = syncer @out = out @in = input end |
Instance Method Details
#run(args = ARGV) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/monster/remote/cli.rb', line 14 def run(args=ARGV) = (args) show_version if [:show_version] password = nil config = Configuration.new if [:password] || config.password_required? password = wait_for_password end connection_wrapper = [:wrapper] || Monster::Remote::Wrappers::NetFTP local_dir = [:local_dir] || config.local_dir || Dir.pwd remote_dir = [:remote_dir] || config.remote_dir || File.basename(local_dir) out = ([:verbose] || config.verbose?) ? STDOUT : nil host = [:host] || config.host || "localhost" port = [:port] || config.port || 21 user = [:user] || config.user || nil sync = @syncer.new(connection_wrapper, local_dir, remote_dir, out) sync.start(user, password, host, port) end |
#show_version ⇒ Object
37 38 39 40 |
# File 'lib/monster/remote/cli.rb', line 37 def show_version @out.puts Monster::Remote::VERSION exit(0) end |
#wait_for_password ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/monster/remote/cli.rb', line 42 def wait_for_password @out.print "password:" system("stty -echo") password = @in.gets.strip system("stty echo") system("echo \"\"") password end |