Class: App::CLI::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/app-cli.rb

Constant Summary collapse

@@subcommands =
[]
@@options =
[]

Class Method Summary collapse

Class Method Details

.cascadableObject



50
51
52
53
54
# File 'lib/app-cli.rb', line 50

def self.cascadable
  self.subcommands.each do |subcmd|
    return  ARGV[0].capitalize == subcmd && class_defined?(self.to_s+"::"+subcmd) ? self.to_s+"::"+subcmd : nil
  end
end

.cascadingObject



43
44
45
46
47
48
# File 'lib/app-cli.rb', line 43

def self.cascading
  if subcmd = self.cascadable
    ARGV.shift
    eval(subcmd)
  end
end

.optionsObject



39
40
41
# File 'lib/app-cli.rb', line 39

def self.options
  self.class_variable_defined?(:@@options) ? @@options : []
end

.subcommandsObject



35
36
37
# File 'lib/app-cli.rb', line 35

def self.subcommands
  self.class_variable_defined?(:@@subcommands) ? @@subcommands : []
end