Sha256: 916c03cc9929a69542bd8c1778345fae7d6cdb3e1996406bfdfcd37ba4f85d11
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
module Nuvado class Keys < BaseCommand desc "list [--source=[local|remote]]", "list your keys" option :source def list case options[:source] when "local" terminal.say Backend::LocalKey.all.map(&:filename).join("\n") when "remote" authenticating_action do terminal.say Backend::Key.all.map(&:title).join("\n") end else terminal.say "Local keys:" terminal.say Backend::LocalKey.all.map(&:filename).join("\n") terminal.say "Associated Keys:" authenticating_action do terminal.say Backend::Key.all.map(&:title).join("\n") end end end desc "add [TITLE]", "add a new key" def add(title = nil) authenticating_action do if key = get_or_generate_local_key title ||= terminal.ask("Preparing to upload #{key.filename}. What title do you want to give it?") remote_key = Backend::Key.from_local_key(key, title) unless remote_key.save terminal.say remote_key.errors.full_messages.join(", ") end else terminal.say("Ok, remember that you'll need one if you want to upload code") end end end private def get_or_generate_local_key local_keys = Backend::LocalKey.all case local_keys.length when 0 Backend::LocalKey.generate if terminal.agree("Could not find a existing public key. Do you want me to create one? [Yn]") when 1 terminal.say("Found a existing key: #{local_keys.first.filepath}") local_keys.first else terminal.say("Found these keys:") terminal.choose do |menu| menu.prompt = "Please choose the one you want to use:" menu.choices(*local_keys) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nuvado-1.0.0.rc3 | lib/nuvado/keys.rb |
nuvado-1.0.0.rc2 | lib/nuvado/keys.rb |
nuvado-1.0.0.rc1 | lib/nuvado/keys.rb |