Class: Sfctl::Commands::Time::Connections::Get

Inherits:
Sfctl::Command show all
Defined in:
lib/sfctl/commands/time/connections/get.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

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) ⇒ Get

Returns a new instance of Get.



9
10
11
12
# File 'lib/sfctl/commands/time/connections/get.rb', line 9

def initialize(options)
  @options = options
  @pastel = Pastel.new(enabled: !@options['no-color'])
end

Instance Method Details

#execute(output: $stdout) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sfctl/commands/time/connections/get.rb', line 14

def execute(output: $stdout)
  read_link_config

  if config.fetch(:connections).nil?
    output.puts @pastel.yellow('You have no connections. Please add them before continue.')
    return
  end

  print_connections(output)
rescue TTY::Config::ReadError
  error_message = 'Please initialize time before continue and ensure that your account authenticated.'
  output.puts @pastel.yellow(error_message)
end