Class: Flare::Tools::Cli::Dispatch

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

Constant Summary collapse

Cli =
Flare::Tools::Cli

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 collapse

Attributes included from Option

#optp

Instance Method Summary collapse

Methods included from Option

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

Methods included from Util::Logging

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

Constructor Details

#initializeDispatch

Returns a new instance of Dispatch.



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

def initialize
  @subcommands = {
    'activate'    => Cli::Activate,
    'balance'     => Cli::Balance,
    'down'        => Cli::Down,
    'dump'        => Cli::Dump,
    'dumpkey'     => Cli::Dumpkey,
    'index'       => Cli::Index,
    'list'        => Cli::List,
    'master'      => Cli::Master,
    'part'        => Cli::Part,
    'ping'        => Cli::Ping,
    'reconstruct' => Cli::Reconstruct,
    'remove'      => Cli::Remove,
    'restore'     => Cli::Restore,
    'slave'       => Cli::Slave,
    'stats'       => Cli::Stats,
    'summary'     => Cli::Summary,
    'threads'     => Cli::Threads,
    'verify'      => Cli::Verify,
  }
end

Instance Attribute Details

#subcommandsObject

Returns the value of attribute subcommands.



18
19
20
# File 'lib/flare/tools/cli/dispatch.rb', line 18

def subcommands
  @subcommands
end

Instance Method Details

#main(subcommand_name, argv, as_subcommand) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/flare/tools/cli/dispatch.rb', line 43

def main(subcommand_name, argv, as_subcommand)
  prepare
  _main(subcommand_name, argv, as_subcommand)
rescue => e
  level = 1
  error(e.to_s)
  e.backtrace.each do |line|
    error("  %3s: %s" % [level, line])
    level += 1
  end
  raise e if $DEBUG
  STATUS_NG
end