Class: Kerbi::Cli::ConfigHandler

Inherits:
BaseHandler show all
Defined in:
lib/cli/config_handler.rb

Instance Method Summary collapse

Instance Method Details

#get(key) ⇒ Object



22
23
24
# File 'lib/cli/config_handler.rb', line 22

def get(key)
  echo run_opts.options[key]
end

#locationObject



6
7
8
# File 'lib/cli/config_handler.rb', line 6

def location
  echo Kerbi::ConfigFile.file_path
end

#resetObject



34
35
36
37
38
# File 'lib/cli/config_handler.rb', line 34

def reset
  Kerbi::ConfigFile.reset
  echo("Config reset".colorize(:green))
  echo("See #{Kerbi::ConfigFile.file_path}")
end

#set(key, new_value) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/cli/config_handler.rb', line 11

def set(key, new_value)
  raise_if_bad_write(key)
  old_value = run_opts.options[key]
  Kerbi::ConfigFile.patch(key => new_value)

  name = "config[#{key}]"
  change_str = "from #{old_value} => #{new_value}"
  echo "Updated #{name} #{change_str}".colorize(:green)
end

#showObject



27
28
29
30
31
# File 'lib/cli/config_handler.rb', line 27

def show
  src = run_opts.options
  hash = Hash[legal_keys.map { |k| [k, src[k]] }]
  echo_data(hash)
end