Class: Sfctl::Commands::Auth::Init
- Inherits:
-
Sfctl::Command
- Object
- Sfctl::Command
- Sfctl::Commands::Auth::Init
- Defined in:
- lib/sfctl/commands/auth/init.rb
Constant Summary
Constants inherited from Sfctl::Command
Sfctl::Command::CONFIG_FILENAME, Sfctl::Command::CONFIG_PATH, Sfctl::Command::HARVEST_PROVIDER, Sfctl::Command::LINK_CONFIG_FILENAME, Sfctl::Command::LINK_CONFIG_PATH, Sfctl::Command::PROVIDERS_LIST, Sfctl::Command::TOGGL_PROVIDER
Instance Method Summary collapse
- #execute(output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Init
constructor
A new instance of Init.
Methods inherited from Sfctl::Command
#access_token, #command, #config, #config_present?, #link_config_present?, #read_config, #read_link_config, #save_config!, #save_link_config!
Constructor Details
#initialize(options) ⇒ Init
Returns a new instance of Init.
11 12 13 14 |
# File 'lib/sfctl/commands/auth/init.rb', line 11 def initialize() @options = @pastel = Pastel.new(enabled: !@options['no-color']) end |
Instance Method Details
#execute(output: $stdout) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/sfctl/commands/auth/init.rb', line 16 def execute(output: $stdout) access_token = ::TTY::Prompt.new.ask("Access token(#{@options['starfish-host']}):", required: true) spinner = ::TTY::Spinner.new('[:spinner] Checking token ...') spinner.auto_spin token_valid?(access_token) ? update_config!(spinner, output, access_token) : render_error(spinner, output) end |