class Sfctl::Commands::Time::Providers::Unset

Public Class Methods

new(options) click to toggle source
# File lib/sfctl/commands/time/providers/unset.rb, line 10
def initialize(options)
  @options = options
  @pastel = Pastel.new(enabled: !@options['no-color'])
end

Public Instance Methods

execute(output: $stdout) click to toggle source
# File lib/sfctl/commands/time/providers/unset.rb, line 15
def execute(output: $stdout)
  return unless config_present?(output)

  prompt = ::TTY::Prompt.new
  provider = prompt.select('Unsetting:', PROVIDERS_LIST)

  if config.fetch(:providers, provider).nil?
    output.puts @pastel.yellow("[#{provider}] is already deleted from configuration.")
  elsif prompt.yes?('Do you want to remove the delete the configuration?')
    remove_provider!(provider, output)
  end
end

Private Instance Methods

remove_provider!(provider, output) click to toggle source
# File lib/sfctl/commands/time/providers/unset.rb, line 30
def remove_provider!(provider, output)
  providers = config.fetch(:providers)
  providers.delete(provider)
  config.set(:providers, value: providers)
  save_config!
  output.puts @pastel.green("Configuration for provider [#{provider}] was successfully deleted.")
end