Class: Wakame::Runner::AdministratorCommand
- Inherits:
-
Object
- Object
- Wakame::Runner::AdministratorCommand
- Defined in:
- lib/wakame/runner/administrator_command.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ AdministratorCommand
constructor
A new instance of AdministratorCommand.
- #parse(args = @args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ AdministratorCommand
Returns a new instance of AdministratorCommand.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wakame/runner/administrator_command.rb', line 20 def initialize(args) @args = args.dup @options = { :command_server_uri => Wakame.config.http_command_server_uri, :json_print => false, :public_key => '1234567890' } load_subcommands end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
18 19 20 |
# File 'lib/wakame/runner/administrator_command.rb', line 18 def @options end |
Instance Method Details
#parse(args = @args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/wakame/runner/administrator_command.rb', line 31 def parse(args=@args) args = args.dup comm_parser = OptionParser.new { |opts| opts.version = Wakame::VERSION opts. = "Usage: wakameadm [options] command [options]" opts.separator " " opts.separator "Sub Commands:" opts.separator show_subcommand_summary() opts.separator " " opts.separator "Common Options:" opts.on( "-s", "--server HttpURI", "command server" ) {|str| @options[:command_server_uri] = str } opts.on("--dump", "Print corresponded message body for debugging"){|j| @options[:json_print] = true } } comm_parser.order!(args) @options.freeze return parse_subcommand(args) end |
#run ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/wakame/runner/administrator_command.rb', line 52 def run parse #if Wakame.config.enable_authentication == "true" # get_params = authentication(req[:command_server_uri], req[:query_string]) #else # get_params = req[:command_server_uri] + req[:query_string] #end begin requester = JsonRequester.new(.dup, {:action=>@subcmd.class.command_name}) @subcmd.run(requester) @subcmd.print_result rescue JsonRequester::ResponseError => e abort(e) rescue => e abort("Unknown Error: #{e}\n" + e.backtrace.join("\n") ) end exit 0 end |