Method: Dry::CLI::Usage.commands_and_arguments
- Defined in:
- lib/dry/cli/usage.rb
.commands_and_arguments(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.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dry/cli/usage.rb', line 33 def self.commands_and_arguments(result) max_length = 0 ret = commands(result).each_with_object({}) do |(name, node), memo| args = if node.command && node.leaf? && node.children? ROOT_COMMAND_WITH_SUBCOMMANDS_BANNER elsif node.leaf? arguments(node.command) else SUBCOMMAND_BANNER end partial = " #{command_name(result, name)}#{args}" max_length = partial.bytesize if max_length < partial.bytesize memo[partial] = node end [max_length, ret] end |