lib/awskeyring_command.rb in awskeyring-0.0.4 vs lib/awskeyring_command.rb in awskeyring-0.0.5

- old
+ new

@@ -76,11 +76,11 @@ account: cred.attributes[:label], key: cred.attributes[:account], secret: cred.password, token: token ) - pid = spawn(env_vars, command.join(' ')) + pid = Process.spawn(env_vars, command.join(' ')) Process.wait pid end desc 'add ACCOUNT', 'Adds an ACCOUNT to the keyring' method_option :key, type: :string, aliases: '-k', desc: 'AWS account key id.' @@ -202,16 +202,19 @@ puts "Authentication valid until #{response.credentials[:expiration]}" end desc 'console ACCOUNT', 'Open the AWS Console for the ACCOUNT' + method_option :path, type: :string, aliases: '-p', desc: 'The service PATH to open.' def console(account = nil) # rubocop:disable all account = ask_missing(existing: account, message: 'account name') cred, temp_cred = get_valid_item_pair(account: account) token = temp_cred.password unless temp_cred.nil? - console_url = 'https://console.aws.amazon.com/console/home' + path = options[:path] || 'console' + + console_url = "https://console.aws.amazon.com/#{path}/home" signin_url = 'https://signin.aws.amazon.com/federation' policy_json = { Version: '2012-10-17', Statement: [{ Action: '*', @@ -249,10 +252,10 @@ signin_token_param = '&SigninToken=' + CGI.escape(signin_token) destination_param = '&Destination=' + CGI.escape(console_url) login_url = signin_url + '?Action=login' + signin_token_param + destination_param - pid = spawn("open \"#{login_url}\"") + pid = Process.spawn("open \"#{login_url}\"") Process.wait pid end # autocomplete desc 'awskeyring CURR PREV', 'Autocompletion for bourne shells', hide: true