Class: Flare::Tools::Cli::SubCommand

Inherits:
Object
  • Object
show all
Includes:
Option, Util::Interruption, Util::Logging
Defined in:
lib/flare/tools/cli/sub_command.rb

Constant Summary collapse

S_OK =
0
S_NG =
1
@@myname =
{}
@@desc =
{}
@@usage =
{}

Constants included from Util::Interruption

Util::Interruption::InterruptionTargets

Constants included from Util::Constant

Util::Constant::DefalutBwlimit, Util::Constant::DefaultIndexServerName, Util::Constant::DefaultIndexServerPort, Util::Constant::DefaultNodePort, Util::Constant::DefaultTimeout, Util::Constant::STATUS_NG, Util::Constant::STATUS_OK

Instance Attribute Summary

Attributes included from Option

#optp

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Interruption

included, #initialize_interruption, #interrupt, #interrupt_, interrupt_all, #interrupted?, #interruptible, #interruptible?

Methods included from Util::Logging

#debug, #error, #fatal, #info, logger, #puts, set_logger, #trace, #warn

Methods included from Option

#option_init, #parse_options, #set_option_dry_run, #set_option_force, #set_option_global, #set_option_index_server

Constructor Details

#initializeSubCommand

Returns a new instance of SubCommand.



58
59
60
# File 'lib/flare/tools/cli/sub_command.rb', line 58

def initialize
  option_init
end

Class Method Details

.desc(desc = nil) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/flare/tools/cli/sub_command.rb', line 40

def self.desc(desc = nil)
  if desc.nil?
    @@desc[name] = "" unless @@desc.has_key?(name)
    @@desc[name]
  else
    @@desc[name] = desc
  end
end

.myname(myname = nil) ⇒ Object



27
28
29
# File 'lib/flare/tools/cli/sub_command.rb', line 27

def self.myname(myname = nil)
  if myname.nil? then @@myname[name] else @@myname[name] = myname end
end

.to_sObject



54
55
56
# File 'lib/flare/tools/cli/sub_command.rb', line 54

def self.to_s
  self.to_sym.to_s
end

.to_symObject



23
24
25
# File 'lib/flare/tools/cli/sub_command.rb', line 23

def self.to_sym
  myname
end

.usage(usage = nil) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/flare/tools/cli/sub_command.rb', line 31

def self.usage(usage = nil)
  if usage.nil?
    @@usage[name] = "" unless @@usage.has_key?(name)
    @@usage[name]
  else
    @@usage[name] = usage
  end
end

Instance Method Details

#executeObject



73
74
75
# File 'lib/flare/tools/cli/sub_command.rb', line 73

def execute
  raise "execute"
end

#execute_subcommand(config, args) ⇒ Object



66
67
68
69
70
71
# File 'lib/flare/tools/cli/sub_command.rb', line 66

def execute_subcommand(config, args)
  setup
  rest_args = parse_options(config, args)

  execute(config, rest_args)
end

#mynameObject



49
50
51
52
# File 'lib/flare/tools/cli/sub_command.rb', line 49

def myname
  myname = @@myname[self.class.name]
  if myname.nil? then "" else myname end
end

#setupObject



62
63
64
# File 'lib/flare/tools/cli/sub_command.rb', line 62

def setup
  set_option_global
end