Module: Clamp::Help
- Included in:
- Command
- Defined in:
- lib/clamp/help.rb
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.
12 13 14 |
# File 'lib/clamp/help.rb', line 12 def declared_usage_descriptions @declared_usage_descriptions end |
#description ⇒ Object
Returns the value of attribute description.
27 28 29 |
# File 'lib/clamp/help.rb', line 27 def description @description end |
Instance Method Details
#banner(description) ⇒ Object
23 24 25 |
# File 'lib/clamp/help.rb', line 23 def (description) self.description = description end |
#derived_usage_description ⇒ Object
29 30 31 32 33 |
# File 'lib/clamp/help.rb', line 29 def derived_usage_description parts = ["[OPTIONS]"] parts += parameters.map { |a| a.name } parts.join(" ") end |
#help(invocation_path, builder = Builder.new) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/clamp/help.rb', line 39 def help(invocation_path, builder = Builder.new) help = builder help.add_usage(invocation_path, usage_descriptions) help.add_description(description) if has_parameters? help.add_list("Parameters", parameters) end if has_subcommands? help.add_list("Subcommands", recognised_subcommands) end help.add_list("Options", ) help.string end |
#usage(usage) ⇒ Object
7 8 9 10 |
# File 'lib/clamp/help.rb', line 7 def usage(usage) @declared_usage_descriptions ||= [] @declared_usage_descriptions << usage end |
#usage_descriptions ⇒ Object
35 36 37 |
# File 'lib/clamp/help.rb', line 35 def usage_descriptions declared_usage_descriptions || [derived_usage_description] end |