From 253f0637e52ad48630582b52b2d35501cc4f5c01 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 8 Jan 2015 17:16:21 -0500 Subject: [PATCH] Add a -t command for setting the login token --- plugins/commands/login/command.rb | 12 ++++++++++++ plugins/commands/login/locales/en.yml | 2 ++ 2 files changed, 14 insertions(+) diff --git a/plugins/commands/login/command.rb b/plugins/commands/login/command.rb index e16b1afaf..ce0dd7fc9 100644 --- a/plugins/commands/login/command.rb +++ b/plugins/commands/login/command.rb @@ -18,6 +18,10 @@ module VagrantPlugins o.on("-k", "--logout", "Logs you out if you're logged in") do |k| options[:logout] = k end + + o.on("-t", "--token TOKEN", String, "Set the Atlas token") do |t| + options[:token] = t + end end # Parse the options @@ -31,6 +35,8 @@ module VagrantPlugins return execute_check elsif options[:logout] return execute_logout + elsif options[:token] + return execute_token(options[:token]) end # Let the user know what is going on. @@ -78,6 +84,12 @@ module VagrantPlugins @env.ui.success(I18n.t("login_command.logged_out")) return 0 end + + def execute_token(token) + @client.store_token(token) + @env.ui.success(I18n.t("login_command.token_saved")) + return 0 + end end end end diff --git a/plugins/commands/login/locales/en.yml b/plugins/commands/login/locales/en.yml index 51020df1d..74b7ee1cd 100644 --- a/plugins/commands/login/locales/en.yml +++ b/plugins/commands/login/locales/en.yml @@ -28,3 +28,5 @@ en: You are now logged in. logged_out: |- You are logged out. + token_saved: |- + The token was successfully saved.