Method: Kontena::Cli::Stacks::Registry::SearchCommand#execute

Defined in:
lib/kontena/cli/stacks/registry/search_command.rb

#executeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/kontena/cli/stacks/registry/search_command.rb', line 24

def execute
  results = stacks_client.search(query.to_s, tags: tag_list, include_prerelease: pre?, include_private: priv?)
  exit_with_error 'Nothing found' if results.empty?
  print_table(results.map { |r| r['attributes'] }) do |row|
    next if quiet?
    row['name'] = '%s/%s' % [row['organization-id'], row['name']]
    row['name'] = pastel.yellow(row['name']) if row['is-private']
    if row['latest-version'] && row['latest-version']['version']
      row['version'] = row['latest-version']['version']
      row['description'] = row['latest-version']['description']
    else
      row['version'] = '?'
    end

    row['description'] = '-' if row['description'].to_s.empty?
  end
end