class Benry::CLI::Action
Constants
- SUBCLASSES
Public Class Methods
inherited(subclass)
click to toggle source
# File lib/benry/cli.rb, line 269 def self.inherited(subclass) #; [!al5pr] provides @action and @option for subclass. subclass.class_eval do @__mappings = [] @__defining = nil @action = proc do |action_name, desc| option_schemas = [] option_schemas << OptionSchema.parse("-h, --help", "print help message") method_name = nil @__defining = [action_name, desc, option_schemas, method_name] end #; [!ymtsg] allows block argument to @option. @option = proc do |symbol, defstr, desc, &callback| #; [!v76cf] can take symbol as kwarg name. if ! symbol.is_a?(Symbol) defstr, desc = symbol, defstr symbol = nil end #; [!di9na] raises error when @option.() called without @action.(). @__defining or raise OptionDefinitionError.new("@option.(#{defstr.inspect}): @action.() should be called prior to @option.().") option_schemas = @__defining[2] option_schemas << OptionSchema.parse(defstr, desc, name: symbol, &callback) end end #; [!4otr6] registers subclass. SUBCLASSES << subclass end
method_added(method_name)
click to toggle source
# File lib/benry/cli.rb, line 298 def self.method_added(method_name) #; [!syzvc] registers action with method. if @__defining @__defining[-1] = method_name @__mappings << @__defining #; [!m7y8p] clears current action definition. @__defining = nil end end
prefix()
click to toggle source
# File lib/benry/cli.rb, line 308 def self.prefix return @prefix end
prefix=(prefix)
click to toggle source
# File lib/benry/cli.rb, line 312 def self.prefix=(prefix) @prefix = prefix end