Class: TempestTime::Commands::Config::Auth

Inherits:
TempestTime::Command show all
Defined in:
lib/tempest_time/commands/config/auth.rb

Instance Method Summary collapse

Methods inherited from TempestTime::Command

#command, #current_user, #date_prompt, #execute, #find_user, #pastel, #prompt, #spinner, #table, #week_prompt, #with_spinner, #with_success_fail_spinner

Methods included from Helpers::GitHelper

#automatic_issue

Methods included from Helpers::FormattingHelper

#braced, #with_percent_sign

Methods included from Helpers::TimeHelper

#beginning_of_week, #dates_in_range, #end_of_week, #formatted_date, #formatted_date_range, #formatted_time, #formatted_time_for_input, #formatted_time_long, #future_dates, #parsed_time, #past_dates, #past_week_selections, #week_beginnings, #week_dates

Constructor Details

#initialize(options) ⇒ Auth

Returns a new instance of Auth.



10
11
12
# File 'lib/tempest_time/commands/config/auth.rb', line 10

def initialize(options)
  @options = options
end

Instance Method Details

#execute!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tempest_time/commands/config/auth.rb', line 14

def execute!
  settings = TempestTime::Settings::Authorization.new
  setting = prompt.select(
    "Which #{pastel.green('setting')} would you like to edit?",
    settings.keys
  )

  new_value = prompt.ask(
    "Enter the #{pastel.green('new value')}.",
    default: settings.fetch(setting)
  )

  if new_value != settings.fetch(setting)
    settings.set(setting, new_value)
    prompt.say(pastel.green('Setting updated!'))
  else
    prompt.say('Nothing changed.')
  end

  execute if prompt.yes?('Keep editing?')
end