Module: CLI::Kit::CommandHelp
- Extended by:
- T::Sig
- Includes:
- Kernel
- Included in:
- BaseCommand
- Defined in:
- lib/cli/kit/command_help.rb
Defined Under Namespace
Modules: ClassMethods
Class Attribute Summary collapse
-
.max_desc_length ⇒ Object
writeonly
Sets the attribute max_desc_length.
-
.tool_name ⇒ Object
writeonly
Sets the attribute tool_name.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from T::Sig
Class Attribute Details
.max_desc_length=(value) ⇒ Object (writeonly)
Sets the attribute max_desc_length
56 57 58 |
# File 'lib/cli/kit/command_help.rb', line 56 def max_desc_length=(value) @max_desc_length = value end |
.tool_name=(value) ⇒ Object (writeonly)
Sets the attribute tool_name
53 54 55 |
# File 'lib/cli/kit/command_help.rb', line 53 def tool_name=(value) @tool_name = value end |
Class Method Details
._max_desc_length ⇒ Object
68 69 70 |
# File 'lib/cli/kit/command_help.rb', line 68 def _max_desc_length @max_desc_length || 80 end |
._tool_name ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/cli/kit/command_help.rb', line 59 def _tool_name unless @tool_name raise 'You must set CLI::Kit::CommandHelp.tool_name=' end @tool_name end |
Instance Method Details
#call(args, name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cli/kit/command_help.rb', line 12 def call(args, name) begin opts = self.class.opts_class opts_inst = opts.new defn = Args::Definition.new opts_inst.define!(defn) tokens = Args::Tokenizer.tokenize(args) parse = Args::Parser.new(defn).parse(tokens) evl = Args::Evaluation.new(defn, parse) opts_inst.evaluate!(evl) rescue Args::Evaluation::TooManyPositions, Args::Evaluation::MissingRequiredPosition => e STDERR.puts CLI::UI.fmt("{{red:{{bold:Error: #{e.}}}}}") STDERR.puts STDERR.puts self.class.build_help raise(AbortSilent) rescue Args::Error => e raise(Abort, e) end if opts_inst.helpflag puts self.class.build_help else invoke_wrapper(opts_inst, name) end end |
#invoke(op, name) ⇒ Object
45 46 47 |
# File 'lib/cli/kit/command_help.rb', line 45 def invoke(op, name) raise(NotImplementedError, '#invoke must be implemented, or #call overridden') end |
#invoke_wrapper(op, name) ⇒ Object
40 41 42 |
# File 'lib/cli/kit/command_help.rb', line 40 def invoke_wrapper(op, name) invoke(op, name) end |