Class: Heroku::Command::Keys

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/commands/keys.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from Base

#app_urls, #ask, #display, #error, #escape, #extract_app, #extract_app_in_dir, #extract_option, #format_date, #git_remotes, #git_url, #heroku, #initialize, #shell, #web_url

Methods included from Helpers

#home_directory, #running_on_a_mac?, #running_on_windows?

Constructor Details

This class inherits a constructor from Heroku::Command::Base

Instance Method Details

#addObject



17
18
19
20
21
22
23
# File 'lib/heroku/commands/keys.rb', line 17

def add
	keyfile = args.first || find_key
	key = File.read(keyfile)

	display "Uploading ssh public key #{keyfile}"
	heroku.add_key(key)
end

#clearObject



30
31
32
33
# File 'lib/heroku/commands/keys.rb', line 30

def clear
	heroku.remove_all_keys
	display "All keys removed."
end

#listObject Also known as: index



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/heroku/commands/keys.rb', line 3

def list
	long = args.any? { |a| a == '--long' }
	keys = heroku.keys
	if keys.empty?
		display "No keys for #{heroku.user}"
	else
		display "=== #{keys.size} key#{'s' if keys.size > 1} for #{heroku.user}"
		keys.each do |key|
			display long ? key.strip : format_key_for_display(key)
		end
	end
end

#removeObject



25
26
27
28
# File 'lib/heroku/commands/keys.rb', line 25

def remove
	heroku.remove_key(args.first)
	display "Key #{args.first} removed."
end