Add a -t command for setting the login token

This commit is contained in:
Seth Vargo 2015-01-08 17:16:21 -05:00
parent 5889c9ceb1
commit 253f0637e5
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -28,3 +28,5 @@ en:
You are now logged in.
logged_out: |-
You are logged out.
token_saved: |-
The token was successfully saved.