Class: Klimt::Command

Inherits:
Thor
  • Object
show all
Includes:
Klimt::Commands::Rendering, ZshCompletion::Command
Defined in:
lib/klimt/command.rb

Instance Method Summary collapse

Methods included from Klimt::Commands::Rendering

#jq_installed?, #render, #render_pretty, #render_with_jq

Instance Method Details

#count(type, *params) ⇒ Object



32
33
34
35
36
# File 'lib/klimt/command.rb', line 32

def count(type, *params)
  client = GravityClient.new(env: options[:env])
  count = client.count(type: type, params: params)
  puts count
end

#find(type, id) ⇒ Object



18
19
20
21
22
# File 'lib/klimt/command.rb', line 18

def find(type, id)
  client = GravityClient.new(env: options[:env])
  response = client.find(type: type, id: id)
  render response
end

#list(type, *params) ⇒ Object



25
26
27
28
29
# File 'lib/klimt/command.rb', line 25

def list(type, *params)
  client = GravityClient.new(env: options[:env])
  response = client.list(type: type, params: params)
  render response
end

#search(term, *params) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/klimt/command.rb', line 42

def search(term, *params)
  if options[:lucky]
    params << 'size=1'
    jq_filter = '.[0] | { model, id, display }'
  end
  indexes = options[:indexes] unless options[:indexes].nil?

  client = GravityClient.new(env: options[:env])
  response = client.search(term: term, params: params, indexes: indexes)
  render response, jq_filter: jq_filter
end

#versionObject



55
56
57
# File 'lib/klimt/command.rb', line 55

def version
  puts Klimt::VERSION
end