Class: Ace::Support::Cli::Help::Usage
- Inherits:
-
Object
- Object
- Ace::Support::Cli::Help::Usage
- Defined in:
- lib/ace/support/cli/help/usage.rb
Constant Summary collapse
- COLUMN_WIDTH =
34
Instance Method Summary collapse
-
#initialize(registry, program_name: nil) ⇒ Usage
constructor
A new instance of Usage.
- #render ⇒ Object
- #render_concise ⇒ Object
Constructor Details
#initialize(registry, program_name: nil) ⇒ Usage
Returns a new instance of Usage.
10 11 12 13 |
# File 'lib/ace/support/cli/help/usage.rb', line 10 def initialize(registry, program_name: nil) @registry = registry @program_name = program_name end |
Instance Method Details
#render ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ace/support/cli/help/usage.rb', line 15 def render usage = "Usage: #{resolved_program_name} [COMMAND]" commands = visible_commands groups = command_groups output = [usage, if groups && !groups.empty? format_grouped(commands, groups) else format_flat(commands, header: "COMMANDS") end].join("\n\n") examples = help_examples output += "\n\n#{format_examples(examples)}" if examples && !examples.empty? output end |
#render_concise ⇒ Object
30 31 32 33 |
# File 'lib/ace/support/cli/help/usage.rb', line 30 def render_concise output = format_flat(visible_commands, header: "Commands:") output + "\n\nRun '#{resolved_program_name} --help' for more info. Each command has its own --help." end |