Sha256: 73cc8beb957494d30baa8e1a0ad6f9c562bd6d14c6d87679bfa882f934b3f731
Contents?: true
Size: 834 Bytes
Versions: 16
Compression:
Stored size: 834 Bytes
Contents
module Kontena::Cli::Plugins class SearchCommand < Kontena::Command 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| name = item['name'].sub('kontena-plugin-', '') puts "%-50s %-10s %-60s" % [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
16 entries across 16 versions & 1 rubygems