Class: Ukiryu::CliCommands::ListCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Ukiryu::CliCommands::ListCommand
- Defined in:
- lib/ukiryu/cli_commands/list_command.rb
Overview
List all available tools in the register
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#run ⇒ Object
Execute the list command.
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 ⇒ Object
Execute the list command
8 9 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ukiryu/cli_commands/list_command.rb', line 8 def run setup_register tools = Ukiryu::Register.tools error! 'No tools found in register' if tools.empty? say "Available tools (#{tools.count}):", :cyan # Separate tools into interfaces and standalone tools interfaces = {} standalone_tools = [] tools.sort.each do |name| = Ukiryu::Register.(name.to_sym) if &.implements # This tool implements an interface interface_name = .implements.to_s interfaces[interface_name] ||= [] interfaces[interface_name] << name elsif &.aliases&.any? # Tool has aliases but doesn't implement interface - treat as standalone standalone_tools << name else # Regular standalone tool standalone_tools << name end rescue Ukiryu::Errors::Error # If we can't load metadata, treat as standalone standalone_tools << name end # Display interfaces first interfaces.sort.each do |interface_name, impls| say " #{interface_name}:", :cyan impls.sort.each do |impl_name| tool = Ukiryu::Tool.get(impl_name) version_info = tool.version ? "v#{tool.version}" : 'version unknown' available = tool.available? ? '[✓]' : '[✗]' say " #{available.ljust(4)} #{impl_name.ljust(20)} #{version_info}", tool.available? ? :green : :red rescue Ukiryu::Errors::Error => e say " [?] #{impl_name.ljust(20)} error: #{e.}", :red end end # Display standalone tools standalone_tools.sort.each do |name| tool = Ukiryu::Tool.get(name) version_info = tool.version ? "v#{tool.version}" : 'version unknown' available = tool.available? ? '[✓]' : '[✗]' say " #{available.ljust(4)} #{name.ljust(20)} #{version_info}", tool.available? ? :green : :red rescue Ukiryu::Errors::Error => e say " [?] #{name.ljust(20)} error: #{e.}", :red end end |