Class: Pair::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/pair/cli.rb,
lib/pair/cli/host.rb,
lib/pair/cli/config.rb,
lib/pair/cli/notify.rb,
lib/pair/cli/custom_errors.rb

Direct Known Subclasses

Config, Host, Notify

Defined Under Namespace

Classes: ApiTokenMissingError, Config, EnableSSHError, Host, Notify

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ Cli

Returns a new instance of Cli.



14
15
16
17
# File 'lib/pair/cli.rb', line 14

def initialize(arguments)
  self.arguments = arguments
  self.options   = {}
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



7
8
9
# File 'lib/pair/cli.rb', line 7

def arguments
  @arguments
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/pair/cli.rb', line 7

def options
  @options
end

Class Method Details

.run!(*arguments) ⇒ Object



10
11
12
# File 'lib/pair/cli.rb', line 10

def self.run!(*arguments)
  new(*arguments).run!
end

Instance Method Details

#run!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pair/cli.rb', line 19

def run!
  case command = arguments.shift
  when 'host'
    require "pair/cli/host"
    Host.run!(arguments)
  when 'config'
    require "pair/cli/config"
    Config.run!(arguments)
  when 'notify'
    require "pair/cli/notify"
    Notify.run!(arguments)
  else
    unknown_command(command)
  end
rescue ApiTokenMissingError, EnableSSHError, Pair::Notification::GNTPError => error
  handle_error error.message, false
rescue SystemExit
  raise
rescue Exception => except
  handle_error "  Please contact [email protected], there\n" +
               "  was an issue creating your session.", $-d
end