Sha256: 705ebfae5704befc56b6d45627f4a155ddcc570bb46c9d53da33279bac9099ee

Contents?: true

Size: 1.47 KB

Versions: 29

Compression:

Stored size: 1.47 KB

Contents

require_relative '../common'

module Kontena::Cli::Stacks::Registry
  class SearchCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::Stacks::Common
    include Kontena::Cli::TableGenerator::Helper

    banner "Search for stacks on the stack registry"

    parameter "[QUERY]", "Query string"

    option ['--[no-]pre'], :flag, "Include pre-release versions", default: true
    option ['--[no-]private'], :flag, "Include private stacks", default: true, attribute_name: :priv

    option ['--tag', '-t'], '[TAG]', "Search by tags", multivalued: true

    option ['-q', '--quiet'], :flag, "Output the identifying column only"

    def fields
      quiet? ? ['name'] : %w(name version pulls description)
    end

    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
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.10 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.9 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.8 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.7 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.6 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.5 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.4 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.3 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.2 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.1 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.7.0 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.9 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.8 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.7 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.6 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.5 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.4 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.3 lib/kontena/cli/stacks/registry/search_command.rb
krates-1.6.2 lib/kontena/cli/stacks/registry/search_command.rb