Class: Ukiryu::CliCommands::CommandsCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/ukiryu/cli_commands/commands_command.rb

Overview

List all commands available for a tool

Instance Attribute Summary

Attributes inherited from BaseCommand

#config, #options

Instance Method Summary collapse

Methods inherited from BaseCommand

#apply_cli_options_to_config, #default_register_path, #initialize, #setup_register, #stringify_keys

Constructor Details

This class inherits a constructor from Ukiryu::CliCommands::BaseCommand

Instance Method Details

#run(tool_name) ⇒ Object

Execute the commands command

Parameters:

  • tool_name (String)

    the tool name



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ukiryu/cli_commands/commands_command.rb', line 10

def run(tool_name)
  setup_register

  # Use get for direct tool loading (find_by is being migrated)
  tool = Ukiryu::Tool.get(tool_name.to_sym)
  error!("Tool not found: #{tool_name}\nAvailable tools: #{Ukiryu::Register.tools.sort.join(', ')}") unless tool

  tool_commands = tool.commands
  error! "No commands defined for #{tool_name}" unless tool_commands

  say "Commands for #{tool_name}:", :cyan

  # Group commands by their parent (belongs_to) for hierarchical tools
  grouped = group_commands_by_parent(tool_commands)

  if grouped.key?(nil) && grouped.size == 1
    # Flat structure - no routing/hierarchy
    grouped[nil].each do |cmd|
      display_command(cmd)
    end
  else
    # Hierarchical structure - show routing groups
    display_hierarchical_commands(tool, grouped)
  end
end