class Sfctl::Command

Constants

CONFIG_FILENAME
CONFIG_PATH
HARVEST_PROVIDER
PROVIDERS_LIST
TOGGL_PROVIDER

Public Instance Methods

access_token() click to toggle source
# File lib/sfctl/command.rb, line 42
def access_token
  read_config['access_token']
end
command(**options) click to toggle source

The external commands runner

@see www.rubydoc.info/gems/tty-command

@api public

# File lib/sfctl/command.rb, line 83
def command(**options)
  require 'tty-command'
  TTY::Command.new(options)
end
config() click to toggle source

Main configuration @api public

# File lib/sfctl/command.rb, line 26
def config
  @config ||= begin
    config = TTY::Config.new
    config.append_path Dir.home
    config
  end
end
config_present?(output) click to toggle source
# File lib/sfctl/command.rb, line 46
def config_present?(output)
  read_config
rescue TTY::Config::ReadError
  output.puts Pastel.new(enabled: !@options['no-color']).red('Please authentificate before continue.')
  false
end
execute(*) click to toggle source

Execute this command

@api public

# File lib/sfctl/command.rb, line 71
def execute(*)
  raise(
    NotImplementedError,
    "#{self.class}##{__method__} must be implemented"
  )
end
read_config() click to toggle source
# File lib/sfctl/command.rb, line 38
def read_config
  config.read(CONFIG_PATH, format: :yaml)
end
save_config!() click to toggle source
# File lib/sfctl/command.rb, line 34
def save_config!
  config.write(CONFIG_PATH, format: :yaml, force: true)
end