Class: Ukiryu::CliCommands::DescribeCommand

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

Overview

Show comprehensive documentation for a tool or specific command

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, command_name = nil) ⇒ Object

Execute the describe command

Parameters:

  • tool_name (String)

    the tool name

  • command_name (String, nil) (defaults to: nil)

    optional command name



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

def run(tool_name, command_name = nil)
  setup_register

  # Use find_by for interface-based discovery (ping -> ping_bsd/ping_gnu)
  tool = Ukiryu::Tool.find_by(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

  # Special handling for "help" command - show tool-level help
  if command_name&.to_s == 'help'
    show_tool_help(tool, tool_commands)
    return
  end

  # If no command specified, show overview of all commands
  unless command_name
    describe_tool_overview(tool, tool_commands)
    return
  end

  # Find the specific command
  cmd = tool_commands.find { |c| c.name.to_s == command_name.to_s || c.name.to_sym == command_name.to_sym }
  error! "Command '#{command_name}' not found for #{tool_name}\nAvailable commands: #{tool_commands.map(&:name).join(', ')}" unless cmd

  describe_command(tool, tool_name, command_name, cmd)
end