Class: SSH::Manager::Client
- Inherits:
-
Object
- Object
- SSH::Manager::Client
- Defined in:
- lib/ssh/manager/client.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #execute! ⇒ Object
- #extract_options ⇒ Object
-
#initialize(argv) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(argv) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 |
# File 'lib/ssh/manager/client.rb', line 13 def initialize(argv) = {} @argv = argv end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/ssh/manager/client.rb', line 11 def end |
Instance Method Details
#execute! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ssh/manager/client.rb', line 19 def execute! cli = SSH::Manager::Cli if [:add] puts 'Adding ..' cli.new().add_connection([:add]) elsif [:connect] puts 'Connecting ..' cli.new().connect_to([:connect]) elsif [:delete] puts 'Deleting ..' cli.new().delete([:delete]) elsif [:list] puts 'Listing ..' cli.new().list_all elsif [:update] puts 'Updating ..' cli.new().update([:update]) elsif [:multi] puts 'Connecting to multiple ips' cli.new().multiple_connection([:multi]) elsif [:transfer_key] puts 'Transfering key' cli.new().transfer_key([:transfer_key]) elsif [:search] puts 'Searching ..' cli.new().search_for([:search]) # elsif @options[:settings] # puts 'Settings' # cli.new(@options).settings(@options[:settings]) else cli.new(@argv.first).connect_to(@argv.first) if @argv != [] puts @optparse if @argv ==[] exit end end |
#extract_options ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ssh/manager/client.rb', line 55 def @optparse = OptionParser.new do |opts| opts. = "Usage: sshm [options] ..." [:add] = false opts.on( '-a', '--add ip', 'Add ip to your Connection list' ) do |opt| [:add] = opt end [:transfer_key] = false opts.on( '-t', '--transferkey id', 'transfer key to <id>' ) do |opt| [:transfer_key] = opt end [:connect] = false opts.on( '-c', '--connect id', 'connect to <id>' ) do |opt| [:connect] = opt end [:delete] = false opts.on( '-d', '--delete id', 'delete connection <id>' ) do |opt| [:delete] = opt end [:update] = false opts.on( '-u', '--update id', 'update connection <id>' ) do |opt| [:update] = opt end [:search] = false opts.on( '-s', '--search string', 'search connection for given criteria' ) do |opt| [:search] = opt end [:multi] = false opts.on( '-m', '--multi string', 'connect to multiple ips with given criteria' ) do |opt| [:multi] = opt end [:list] = false opts.on( '-l', '--list', 'list all connections' ) do [:list] = true end opts.on( '-h', '--help', 'Display this screen' ) do puts opts exit end opts.on( '-v', '--version', 'Print programs version' ) do puts SSH::Manager::VERSION exit end end @optparse.parse(@argv) end |