Class: Ace::Support::Cli::Help::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/support/cli/help/usage.rb

Constant Summary collapse

COLUMN_WIDTH =
34

Instance Method Summary collapse

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

#renderObject



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_conciseObject



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