Sha256: 3fec44f64f075ffe46259663e346ff0605426672b56b98529a9351a0038159d7
Contents?: true
Size: 845 Bytes
Versions: 30
Compression:
Stored size: 845 Bytes
Contents
require_relative 'common' module Kontena::Cli::Plugins class SearchCommand < Kontena::Command include Common parameter '[NAME]', 'Search text' def execute results = fetch_plugins(name) exit_with_error("Cannot access plugin server") unless results puts "%-50s %-10s %-60s" % ['NAME', 'VERSION', 'DESCRIPTION'] results.each do |item| puts "%-50s %-10s %-60s" % [short_name(item['name']), item['version'], item['info']] end end def fetch_plugins(name) client = Excon.new('https://rubygems.org') response = client.get( path: "/api/v1/search.json?query=kontena-plugin-#{name}", headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } ) JSON.parse(response.body) rescue nil end end end
Version data entries
30 entries across 30 versions & 1 rubygems