Class: Ace::Support::Nav::CLI::Commands::Resolve
- Inherits:
-
Cli::Command
- Object
- Cli::Command
- Ace::Support::Nav::CLI::Commands::Resolve
- Includes:
- Cli::Base
- Defined in:
- lib/ace/support/nav/cli/commands/resolve.rb
Overview
ace-support-cli Command class for the resolve command
Instance Method Summary collapse
Instance Method Details
#call(uri:, **options) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ace/support/nav/cli/commands/resolve.rb', line 79 def call(uri:, **) # Normalize bare protocol names to protocol:// format for listing uri = normalize_protocol_shorthand(uri) # Handle magic patterns (wildcards → list) if magic_wildcard_pattern?(uri) # Delegate to list command require_relative "list" list_cmd = List.new return list_cmd.call(pattern: uri, **) end # Initialize instance variables for use in private methods @uri = uri @options = @engine = Organisms::NavigationEngine.new execute end |
#execute ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ace/support/nav/cli/commands/resolve.rb', line 99 def execute display_config_summary # Check for cmd:// protocol delegation if @uri.include?("://") protocol = @uri.split("://").first if @engine.cmd_protocol?(protocol) delegator = Organisms::CommandDelegator.new return delegator.delegate(@uri, @options) end end result = @engine.resolve(@uri, content: @options[:content], verbose: @options[:verbose]) if result.nil? raise Ace::Support::Cli::Error.new("Resource not found: #{@uri}") end if @options[:verbose] && result.is_a?(Hash) require "json" puts JSON.pretty_generate(result) elsif @options[:path] # Show path only puts result.is_a?(Hash) ? result[:path] || result : result else puts result end end |