Class: Fontist::ConfigCLI
- Inherits:
-
Thor
- Object
- Thor
- Fontist::ConfigCLI
- Includes:
- Fontist::CLI::ClassOptions
- Defined in:
- lib/fontist/config_cli.rb
Instance Method Summary collapse
Methods included from Fontist::CLI::ClassOptions
#handle_class_options, included, #log_level
Instance Method Details
#delete(key) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fontist/config_cli.rb', line 32 def delete(key) () Config.instance.delete(key) Fontist.ui.success( "'#{key}' reset to default ('#{Config.instance.default_value(key)}').", ) CLI::STATUS_SUCCESS end |
#keys ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/fontist/config_cli.rb', line 42 def keys () Fontist.ui.say("Available keys:") Config.instance.default_values.each do |key, value| Fontist.ui.say("#{key} (default: #{value})") end CLI::STATUS_SUCCESS end |
#set(key, value) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/fontist/config_cli.rb', line 21 def set(key, value) () Config.instance.set(key, value) Fontist.ui.success("'#{key}' set to '#{value}'.") CLI::STATUS_SUCCESS rescue Errors::InvalidConfigAttributeError => e Fontist.ui.error(e.) CLI::STATUS_INVALID_CONFIG_ATTRIBUTE end |
#show ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fontist/config_cli.rb', line 6 def show () values = Config.instance.custom_values if values.empty? Fontist.ui.success("Config is empty.") else Fontist.ui.success("Current config:") Fontist.ui.success(format_hash(values)) end CLI::STATUS_SUCCESS end |