Module: Benry::ActionRunner
- Defined in:
- lib/benry/actionrunner.rb
Defined Under Namespace
Modules: ApplicationHelpBuilderModule, Export Classes: Action, Brownie, GlobalOptionParser, MainApplication
Constant Summary collapse
- VERSION =
"$Release: 0.1.0 $".split()[1]
- DOCUMENT_URL =
"https://kwatch.github.io/benry-ruby/benry-actionrunner.html"
- DEFAULT_FILENAME =
"Actionfile.rb"
- CONFIG =
Benry::CmdApp::Config.new(app_desc, VERSION).tap do |config| action_file = DEFAULT_FILENAME command = File.basename($0) config.app_command = command #config.app_detail = nil x = command example = <<END $ #{x} -h | less # print help message $ #{x} -g # generate action file ('#{action_file}') $ less #{action_file} # confirm action file $ #{x} # list actions (or: `#{x} -l`) $ #{x} -h hello # show help message for 'hello' action $ #{x} hello Alice # run 'hello' action with arguments Hello, Alice! $ #{x} hello Alice -l fr # run 'hello' action with args and options Bonjour, Alice! $ #{x} : # list prefixes of actions (or '::', ':::') $ #{x} xxxx: # list actions starting with 'xxxx:' END config.help_postamble = { "Example:" => example, "Document:" => " #{DOCUMENT_URL}\n", } end
- GLOBAL_OPTION_SCHEMA =
Benry::CmdApp::GLOBAL_OPTION_SCHEMA_CLASS.new(nil).tap do |schema| topics = ["action", "actions", "alias", "aliases", "category", "categories", "abbrev", "abbrevs", "category1", "categories1", "category2", "categories2", "category3", "categories3", "category4", "categories4", "metadata"] schema.add(:help , "-h, --help", "print help message (of action if specified)") schema.add(:version , "-V" , "print version") schema.add(:list , "-l" , "list actions") schema.add(:topic , "-L <topic>", "topic list (actions|aliases|prefixes|abbrevs)", enum: topics) schema.add(:all , "-a" , "list all actions/options including hidden ones") schema.add(:file , "-f <file>" , "actionfile name (default: '#{DEFAULT_FILENAME}')") schema.add(:search , "-u" , "search for actionfile in parent or upper dir") schema.add(:chdir , "-w" , "change current dir to where action file exists") schema.add(:searchdir, "-s" , "same as '-up'", hidden: true) schema.add(:generate , "-g" , "generate actionfile ('#{DEFAULT_FILENAME}') with example code") schema.add(:verbose , "-v" , "verbose mode") schema.add(:quiet , "-q" , "quiet mode") schema.add(:color , "-c" , "enable color mode") schema.add(:nocolor , "-C" , "disable color mode") schema.add(:debug , "-D" , "debug mode") schema.add(:trace , "-T" , "trace mode") schema.add(:dryrun , "-X" , "dry-run mode (not run; just echoback)") end
Class Method Summary collapse
Class Method Details
.main(argv = ARGV) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/benry/actionrunner.rb', line 117 def self.main(argv=ARGV) #; [!wmcup] handles '$ACRIONRUNNER_OPTION' value. envstr = ENV["ACTIONRUNNER_OPTION"] if envstr && ! envstr.empty? argv = envstr.split() + argv end app = MainApplication.new(CONFIG, GLOBAL_OPTION_SCHEMA) status_code = app.main(argv) #; [!hujvl] returns status code. return status_code end |