Class: Ace::Support::Nav::CLI::Commands::List

Inherits:
Cli::Command
  • Object
show all
Includes:
Cli::Base
Defined in:
lib/ace/support/nav/cli/commands/list.rb

Overview

ace-support-cli Command class for the list command

Instance Method Summary collapse

Instance Method Details

#call(pattern:, **options) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/ace/support/nav/cli/commands/list.rb', line 59

def call(pattern:, **options)
  # Initialize instance variables for use in private methods
  @pattern = pattern
  @options = options
  @engine = Organisms::NavigationEngine.new

  execute
end

#executeObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ace/support/nav/cli/commands/list.rb', line 68

def execute
  display_config_summary

  resources = @engine.list(@pattern, tree: @options[:tree], verbose: @options[:verbose])

  if resources.empty?
    raise Ace::Support::Cli::Error.new("No resources found matching: #{@pattern}")
  end

  if @options[:verbose]
    require "json"
    puts JSON.pretty_generate(resources)
  else
    resources.each { |resource| puts resource }
  end
end