Class: Gtmtech::Crypto::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/gtmtech/crypto/CLI.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#subcommandsObject (readonly)

Returns the value of attribute subcommands.



8
9
10
# File 'lib/gtmtech/crypto/CLI.rb', line 8

def subcommands
  @subcommands
end

Class Method Details

.executeObject



32
33
34
# File 'lib/gtmtech/crypto/CLI.rb', line 32

def self.execute
  @@command_class.execute
end

.parseObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gtmtech/crypto/CLI.rb', line 10

def self.parse

  Utils.require_dir 'gtmtech/crypto/subcommands'
  @@subcommands = Utils.find_all_subclasses_of({ :parent_class => Gtmtech::Crypto::Subcommands }).collect {|classname| Utils.snakecase classname}

  subcommand = ARGV.shift
  subcommand = case subcommand
    when nil
      ARGV.delete_if {true}
      "unknown_command"
    when /^\-/
      ARGV.delete_if {true}
      "help"
    else
      subcommand
  end

  @@command_class = Subcommand.find subcommand
  @@options       = @@command_class.parse

end

.subcommandsObject



36
37
38
# File 'lib/gtmtech/crypto/CLI.rb', line 36

def self.subcommands
  @@subcommands
end