Class: Holistics::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/holistics.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = [], local_options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.


42
43
44
45
# File 'lib/holistics.rb', line 42

def initialize(args = [], local_options = {}, config = {})
  require_config! unless %w{help config version}.include? config[:current_command].name
  super
end

Instance Method Details

#config(token = nil) ⇒ Object


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/holistics.rb', line 55

def config(token = nil)
  unless token
    current_config = configured? ? read_config : {}
    current_token = current_config[:token]
    new_token = ask "Your Holistics token [#{current_token.light_black}]: "
    new_token = nil if new_token.blank?
    unless token = new_token || current_token
      STDERR.puts 'Failed to config, empty token provided !'
      exit 1
    end
  end
  verify_token(token) do
    write_config(:token => token)
  end
end

#versionObject


50
51
52
# File 'lib/holistics.rb', line 50

def version
  puts "\nHolistics CommandLine Interface version #{Holistics::VERSION}".yellow
end