Class: Sfctl::Commands::Time::Sync
- Inherits:
-
Sfctl::Command
- Object
- Sfctl::Command
- Sfctl::Commands::Time::Sync
- Defined in:
- lib/sfctl/commands/time/sync.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) ⇒ Sync
constructor
A new instance of Sync.
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) ⇒ Sync
Returns a new instance of Sync.
15 16 17 18 19 |
# File 'lib/sfctl/commands/time/sync.rb', line 15 def initialize() = @pastel = Pastel.new(enabled: !['no-color']) @prompt = ::TTY::Prompt.new end |
Instance Method Details
#execute(output: $stdout) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sfctl/commands/time/sync.rb', line 21 def execute(output: $stdout) return if !config_present?(output) || !link_config_present?(output) if connections.length.zero? output.puts @pastel.red('Please add a connection before continue.') return end sync_assignments(output, assignments_to_sync) rescue ThreadError, JSON::ParserError output.puts output.puts @pastel.red('Something went wrong.') end |