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.