class Giticious::Cli::Pubkey
Public Instance Methods
add(username, pubkey)
click to toggle source
# File lib/giticious/cli/pubkey.rb, line 6 def add(username, pubkey) begin if Giticious::Service::User.new.exists?(username) == false $stderr.puts "A user with this name does not exist" exit 1 end if Giticious::Service::Pubkey.new.add(username, pubkey) puts "Public key \"#{pubkey.split(//).last(80).join}\" for user #{username} has been added!" end list(username) rescue => e $stderr.puts e.message exit 1 end end
delete(pubkey)
click to toggle source
# File lib/giticious/cli/pubkey.rb, line 25 def delete(pubkey) begin Giticious::Service::Pubkey.new.delete(pubkey) rescue => e $stderr.puts e.message exit 1 end end
list(username)
click to toggle source
# File lib/giticious/cli/pubkey.rb, line 35 def list(username) begin rows = [] Giticious::Service::Pubkey.new.user_pubkeys(username).each do |pubkey| rows << [ username, pubkey.split(//).last(80).join ] end table = Terminal::Table.new :headings => ["Username", "Public key (last 80 chars)"], :rows => rows puts table rescue => e $stderr.puts e.message exit 1 end end