Class: DRbQS::Command::Base
- Inherits:
-
Object
- Object
- DRbQS::Command::Base
- Defined in:
- lib/drbqs/command_line/command_base.rb
Constant Summary collapse
- @@command_name =
File.basename($PROGRAM_NAME)
Constants included from Misc
Class Method Summary collapse
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(klass = DRbQS::Setting::Base, help_message = nil) ⇒ Base
constructor
A new instance of Base.
- #setting ⇒ Object
Methods included from Argument
check_argument_size, split_arguments
Methods included from Misc
create_logger, create_uri, output_error, process_running_normally?, random_key, time_to_history_string, time_to_history_string2, uri_drbunix
Constructor Details
#initialize(klass = DRbQS::Setting::Base, help_message = nil) ⇒ Base
Returns a new instance of Base.
15 16 17 18 |
# File 'lib/drbqs/command_line/command_base.rb', line 15 def initialize(klass = DRbQS::Setting::Base, = nil) @help_message = @opt_setting = DRbQS::Command::OptionSetting.new(@help_message, klass.new) end |
Class Method Details
.exec(argv) ⇒ Object
9 10 11 12 13 |
# File 'lib/drbqs/command_line/command_base.rb', line 9 def self.exec(argv) obj = self.new obj.parse_option(argv) obj.exec end |
Instance Method Details
#exec ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/drbqs/command_line/command_base.rb', line 62 def exec begin parse_arguments! setting.exec($stdout) exit_normally rescue DRb::DRbConnError => err $stderr.puts "error: Can not connect. #{err.to_s}" exit_unusually rescue DRbQS::Setting::InvalidArgument => err mes = "error: Invalid command argument. #{err.to_s}\n\n" << @help_message.to_s $stderr.print mes exit_invalid_option rescue => err output_error(err, $stderr) exit_unusually end end |
#setting ⇒ Object
20 21 22 |
# File 'lib/drbqs/command_line/command_base.rb', line 20 def setting @opt_setting.setting end |