class DTK::Client::CLI::Processor::Plugin::Gli
Public Class Methods
new()
click to toggle source
# File lib/cli/processor/plugin/gli.rb, line 25 def initialize @response_obj = nil end
Public Instance Methods
add_command_defaults!()
click to toggle source
# File lib/cli/processor/plugin/gli.rb, line 57 def add_command_defaults! program_desc 'DTK CLI tool' version VERSION subcommand_option_handling :normal arguments :strict end
add_command_hooks!()
click to toggle source
add_command_hooks! works in conjunction with run
# File lib/cli/processor/plugin/gli.rb, line 35 def add_command_hooks! around do |_global_options, _command, _options, _arguments, code| # It is expected that last line in code block returns response @response_obj = code.call end on_error do |err| if err.kind_of?(::GLI::BadCommandLine) or err.kind_of?(::GLI::UnknownCommand) true # so gli mechanism processes it elsif err.kind_of?(Error::ServerNotOkResponse) @response_obj = err.response nil elsif err.kind_of?(Error) raise err elsif err.kind_of?(DTK::Network::Client::Error) raise Error::DtkNetwork.new(err.message, :backtrace => err.backtrace) else raise Error::Client.new(err.message, :backtrace => err.backtrace) end end end
run_and_return_response_object(argv)
click to toggle source
# File lib/cli/processor/plugin/gli.rb, line 29 def run_and_return_response_object(argv) run(argv) @response_obj end