Class: ALib::ConfigurableMain
- Inherits:
-
AbstractMain
- Object
- AbstractMain
- ALib::ConfigurableMain
- Defined in:
- lib/alib-0.4.0/main.rb
Constant Summary
Constants inherited from AbstractMain
AbstractMain::EXIT_FAILURE, AbstractMain::EXIT_PSEUDO_SUCCESS, AbstractMain::EXIT_SUCCESS
Constants included from Logging
Logging::DIV0, Logging::DIV1, Logging::DIV2, Logging::DIV3, Logging::EOL, Logging::SEC0, Logging::SEC1, Logging::SEC2, Logging::SEC3
Constants included from ALib
AUTOLOAD, BSearch, Configfile, Find, LIBDIR, Listfile, METACLASS, OrderedAutoHash, VERSION
Instance Attribute Summary
Attributes inherited from AbstractMain
#argv, #cmdline, #console, #env, #listoptions, #logdev, #logger, #op, #options, #program, #verbosity
Class Method Summary collapse
Instance Method Summary collapse
-
#gen_template(template) ⇒ Object
–}}}.
-
#init_config(opts = @options) ⇒ Object
–}}}.
-
#post_parse_argv ⇒ Object
–}}}.
- #pre_parse_argv ⇒ Object
Methods inherited from AbstractMain
argument, arguments, class_attributes, #die, inherited, #init_logging, #initialize, instance_attributes, #invalid_option, #klass, #logcatch, #main, optional_argument, optional_arguments, #optional_arguments, options, #parse_argv, #parse_options, #post_main, #post_parse_options, #post_run, #pre_main, #pre_parse_options, #pre_run, required_argument, #required_arguments, required_arguments, #run, run, stringlist, unindent_block, #usage
Methods included from Logging
Methods included from Logging::LogMethods
#__logger_mutex, #__logger_sync, #btrace, #emsg, #errmsg, #log_err, #logger, #logger=
Methods included from ALib
configurable_main, load, simple_main, version
Constructor Details
This class inherits a constructor from ALib::AbstractMain
Class Method Details
.class_initialize ⇒ Object
–{{{
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/alib-0.4.0/main.rb', line 536 def self.class_initialize #--{{{ super class_attribute :config_default_path class_attribute :config_search_path class_attribute :configfile config_default_path "#{ prognam }.conf" config_search_path %w(. ~ /usr/local/etc /usr/etc /etc) configfile Class::new(ALib::ConfigFile) #{ default = DATA; DATA.rewind; } optspec << [ '--config=path', 'valid path - specify config file (default nil)' ] optspec << [ '--template=[path]', 'valid path - generate a template config file in path (default stdout)' ] #--}}} end |
Instance Method Details
#gen_template(template) ⇒ Object
–}}}
567 568 569 570 571 572 |
# File 'lib/alib-0.4.0/main.rb', line 567 def gen_template template #--{{{ klass::configfile::gen_template(template) self #--}}} end |
#init_config(opts = @options) ⇒ Object
–}}}
578 579 580 581 582 583 584 585 586 587 588 589 |
# File 'lib/alib-0.4.0/main.rb', line 578 def init_config opts = #--{{{ conf = Util::getopt 'config', opts @config = if conf klass::configfile::new(conf) else klass::configfile::any klass::config_default_path, klass::config_search_path end @config #--}}} end |
#post_parse_argv ⇒ Object
–}}}
573 574 575 576 577 |
# File 'lib/alib-0.4.0/main.rb', line 573 def post_parse_argv #--{{{ init_config #--}}} end |
#pre_parse_argv ⇒ Object
556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/alib-0.4.0/main.rb', line 556 def pre_parse_argv #--{{{ super if(.has_key?('template') or @argv.first =~ %r/template/i) @argv.shift if @argv.first =~ %r/template/i arg = @argv.first gen_template ['template'] || ['config'] || arg exit EXIT_SUCCESS end #--}}} end |