Method: Dry::CLI::Usage.call

Defined in:
lib/dry/cli/usage.rb

.call(result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dry/cli/usage.rb', line 19

def self.call(result)
  header = "Commands:"
  max_length, commands = commands_and_arguments(result)

  commands.map do |banner, node|
    next if node.hidden

    usage = description(node.command) if node.leaf?
    "#{justify(banner, max_length, usage)}#{usage}"
  end.compact.unshift(header).join("\n")
end