Class: Ea::Cli::Command::Query

Inherits:
Base
  • Object
show all
Defined in:
lib/ea/cli/command/query.rb

Overview

ea query FILE [--type=T] [--package=NAME] [--stereo=NAME]

Wraps Ea::Query::Builder for CLI consumption.

Constant Summary collapse

COLUMNS =
%i[id type name package].freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Ea::Cli::Command::Base

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
# File 'lib/ea/cli/command/query.rb', line 12

def call
  builder = Ea::Query::Builder.new(model)
  builder = builder.with_type(options[:type]) if options[:type]
  builder = builder.in_package(options[:package]) if options[:package]
  builder = builder.with_stereotype(options[:stereotype]) if options[:stereotype]
  rows = builder.call.map { |o| [o.object_id, o.object_type, o.name, package_name_for(o)] }
  formatter.render(rows, columns: COLUMNS)
end