class Translatomatic::CLI::Config
Configuration functions for the command line interface
Public Instance Methods
add(key, *value)
click to toggle source
Add a configuration setting to a list @param key [String] configuration key @param value [String] value to add @return [String] the new value
# File lib/translatomatic/cli/config.rb, line 43 def add(key, *value) run { conf.add(key, value, config_params) } end
describe()
click to toggle source
Describe available configuration settings
# File lib/translatomatic/cli/config.rb, line 73 def describe run do print_config_table(columns: %i[key type desc]) end end
list()
click to toggle source
List current configuration settings
# File lib/translatomatic/cli/config.rb, line 63 def list run do print_config_table(columns: %i[key value], skip_blanks: true) end end
set(key, *value)
click to toggle source
Change a configuration setting @param key [String] configuration key @param value [String] new value for the configuration @return [String] the new value
# File lib/translatomatic/cli/config.rb, line 22 def set(key, *value) run { conf.set(key, value, config_params) } end
subtract(key, value)
click to toggle source
Remove a configuration setting from a list @param key [String] configuration key @param value [String] value to remove @return [void]
# File lib/translatomatic/cli/config.rb, line 54 def subtract(key, value) run { conf.subtract(key, value, config_params) } end
unset(key)
click to toggle source
Remove a configuration setting @param key [String] configuration key to remove @return [void]
# File lib/translatomatic/cli/config.rb, line 32 def unset(key) run { conf.unset(key, config_params) } end
Private Instance Methods
config_location()
click to toggle source
# File lib/translatomatic/cli/config.rb, line 85 def config_location if options[:user] :user elsif options[:project] :project end end
config_params()
click to toggle source
# File lib/translatomatic/cli/config.rb, line 81 def config_params { location: config_location, for_file: options['for-file'] } end
config_table_intro()
click to toggle source
# File lib/translatomatic/cli/config.rb, line 106 def config_table_intro if (location = config_location) t('cli.config.location_configuration', location: location) else t('cli.config.configuration') end end
print_config_table(params)
click to toggle source
# File lib/translatomatic/cli/config.rb, line 93 def print_config_table(params) display_options = options.merge(params).merge(config_params) display = Translatomatic::Config::Display.new(display_options) puts config_table_intro + "\n" rows = display.config_table_body if rows.empty? puts t('cli.config.no_config') else print_table(rows) end puts end