Class: Benry::CmdApp::GlobalOptionSchema
- Inherits:
-
OptionSchema
- Object
- Benry::CmdOpt::Schema
- OptionSchema
- Benry::CmdApp::GlobalOptionSchema
- Defined in:
- lib/benry/cmdapp.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ GlobalOptionSchema
constructor
A new instance of GlobalOptionSchema.
- #reorder_options(*keys) ⇒ Object
- #setup(config) ⇒ Object
Constructor Details
#initialize(config) ⇒ GlobalOptionSchema
Returns a new instance of GlobalOptionSchema.
1690 1691 1692 1693 |
# File 'lib/benry/cmdapp.rb', line 1690 def initialize(config) super() setup(config) end |
Instance Method Details
#reorder_options(*keys) ⇒ Object
1732 1733 1734 1735 1736 1737 1738 |
# File 'lib/benry/cmdapp.rb', line 1732 def (*keys) #; [!2cp9s] sorts options in order of keys specified. #; [!xe7e1] moves options which are not included in specified keys to end of option list. n = @items.length @items.sort_by! {|item| keys.index(item.key) || @items.index(item) + n } nil end |
#setup(config) ⇒ Object
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 |
# File 'lib/benry/cmdapp.rb', line 1695 def setup(config) #; [!umjw5] add nothing if config is nil. return if ! config #; [!ppcvp] adds options according to config object. c = config topics = ["action", "actions", "alias", "aliases", "category", "categories", "abbrev", "abbrevs", "category1", "categories1", "category2", "categories2", "category3", "categories3", "category4", "categories4", "metadata"] _add(c, :help , "-h, --help" , "print help message (of action if specified)") _add(c, :version, "-V, --version", "print version") _add(c, :list , "-l, --list" , "list actions and aliases") _add(c, :topic , "-L <topic>" , "topic list (actions|aliases|categories|abbrevs)", enum: topics) _add(c, :all , "-a, --all" , "list hidden actions/options, too") _add(c, :verbose, "-v, --verbose", "verbose mode") _add(c, :quiet , "-q, --quiet" , "quiet mode") _add(c, :color , "--color[=<on|off>]", "color mode", type: TrueClass) _add(c, :debug , " --debug" , "debug mode") _add(c, :trace , "-T, --trace" , "trace mode") _add(c, :dryrun , "-X, --dryrun" , "dry-run mode (not run; just echoback)") end |