require 'rubygems' require 'cli/command' module Factor module CLI class CredentialTask < Command desc "create SERVICE NAME VALUE", "add a key and value for the credential" method_option :key, :type=>:string, :desc=>"File reference containing the symmetric key for encryption" method_option :organization, :type=>:string, :desc=>"Organizoation to which this credential belongs" def create(service,name,value) secret=nil if options[:key] secret=File.read(options[:key]) end puts @client.create_credential(service,name,value,secret,options[:organization]) end desc "list", "get all of the credential" def list() @client.get_credentials["value"].each do |service,values| # puts "#{credential['service']} : #{credential['name']} (#{credential['slug']}): #{credential['value']}" puts "#{service}:" values.each do |key,values| # puts "#{key['value']} (#{value['slug']}) : #{value}" puts " #{key} (#{values['slug']}): ***" end end end desc "delete SERVICE NAME", "remove a value from the credentials bag" def delete(service,name) puts @client.delete_credential(service,name) end end end end