lib/gaptool-client.rb in gaptool-client-0.3.1 vs lib/gaptool-client.rb in gaptool-client-0.3.2
- old
+ new
@@ -245,29 +245,47 @@
class SvcAPIList < Clamp::Command
option [ "-s", "--service"], "SERVICE", "Name of the service, omit to show all"
def execute
if service.nil?
- puts $api.svcapi_showkeys(:all)
+ keyhash = $api.svcapi_showkeys(:all)
+ keyhash.keys.each do |service|
+ puts service.color(:green)
+ keyhash[service].keys.each do |state|
+ puts " ┖ #{state}".color(:cyan)
+ keyhash[service][state].each do |key|
+ puts " - #{key}"
+ end
+ end
+ end
else
- puts $api.svcapi_showkeys(service)
+ keyhash = $api.svcapi_showkeys(service)
+ puts service.color(:green)
+ keyhash.keys.each do |state|
+ puts " ┖ #{state}".color(:cyan)
+ keyhash[state].each do |key|
+ puts " - #{key}"
+ end
+ end
end
end
end
class SvcAPIDelete < Clamp::Command
option [ "-s", "--service"], "SERVICE", "Name of the service", :required => true
option [ "-k", "--key" ], "KEY", "string for storing as a key/deleting", :required => true
def execute
- $api.svcapi_deletekey(service, key)
+ if $api.svcapi_deletekey(service, key)
+ puts "success"
+ end
end
end
class SvcAPIPut < Clamp::Command
option [ "-s", "--service"], "SERVICE", "Name of the service", :required => true
option [ "-k", "--key" ], "KEY", "string for storing as a key/deleting", :required => true
def execute
- $api.svcapi_putkey(service, key)
+ puts $api.svcapi_putkey(service, key)
end
end
class SvcAPI < Clamp::Command
subcommand "list", "List keys for a service or all services", SvcAPIList