Class: Russh::Cli

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/russh/cli.rb

Instance Method Summary collapse

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/russh/cli.rb', line 9

def run
  program :name, 'Russh'
  program :version, VERSION
  program :description, 'SSH Config Manager For Ruby'

  command :create do |c|
    c.syntax = 'russh create [options]'
    c.description = 'Creates a new host'
    c.option '--alias STRING', String, 'Host Alias'
    c.option '--host STRING', String, 'Host Address'
    c.option '--user STRING', String, 'Username'
    c.action do |args, options|
      raise ArgumentError.new("Alias is required!") unless options.alias
      raise ArgumentError.new("Host is required!") unless options.host
      Accessor.new.create options.alias, options.host, options.user
    end
  end

  command :backup do |c|
    c.syntax = 'russh backup'
    c.description = 'Backups your ssh config'
    c.action do
      Accessor.new.backup
    end
  end

  run!
end