Module: Clamp::Help
- Included in:
- Command
- Defined in:
- lib/clamp/help.rb
Overview
Command help generation.
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
-
#declared_usage_descriptions ⇒ Object
readonly
Returns the value of attribute declared_usage_descriptions.
-
#description ⇒ Object
Returns the value of attribute description.
Instance Method Summary collapse
- #banner(description) ⇒ Object
- #derived_usage_description ⇒ Object
- #help(invocation_path, builder = Builder.new) ⇒ Object
- #usage(usage) ⇒ Object
- #usage_descriptions ⇒ Object
Instance Attribute Details
#declared_usage_descriptions ⇒ Object (readonly)
Returns the value of attribute declared_usage_descriptions.
17 18 19 |
# File 'lib/clamp/help.rb', line 17 def declared_usage_descriptions @declared_usage_descriptions end |
#description ⇒ Object
Returns the value of attribute description.
32 33 34 |
# File 'lib/clamp/help.rb', line 32 def description @description end |
Instance Method Details
#banner(description) ⇒ Object
28 29 30 |
# File 'lib/clamp/help.rb', line 28 def (description) self.description = description end |
#derived_usage_description ⇒ Object
34 35 36 37 38 |
# File 'lib/clamp/help.rb', line 34 def derived_usage_description parts = ["[OPTIONS]"] parts += parameters.map(&:name) parts.join(" ") end |
#help(invocation_path, builder = Builder.new) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/clamp/help.rb', line 44 def help(invocation_path, builder = Builder.new) help = builder help.add_usage(invocation_path, usage_descriptions) help.add_description(description) help.add_list(Clamp.(:parameters_heading), parameters) if has_parameters? help.add_list(Clamp.(:subcommands_heading), recognised_subcommands) if has_subcommands? help.add_list(Clamp.(:options_heading), ) help.string end |
#usage(usage) ⇒ Object
12 13 14 15 |
# File 'lib/clamp/help.rb', line 12 def usage(usage) @declared_usage_descriptions ||= [] @declared_usage_descriptions << usage end |
#usage_descriptions ⇒ Object
40 41 42 |
# File 'lib/clamp/help.rb', line 40 def usage_descriptions declared_usage_descriptions || [derived_usage_description] end |