class ConfigCurator::CLI
Thor class for the `curate` command.
Public Instance Methods
collection()
click to toggle source
Makes a collection object to use for the instance. @return [Collection] the collection object
# File lib/config_curator/cli.rb, line 37 def collection @collection ||= Collection.new logger: logger end
install(manifest = 'manifest.yml')
click to toggle source
Installs the collection. @param manifest [String] path to the manifest file to use @return [Boolean] value of {Collection#install} or {Collection#install?}
# File lib/config_curator/cli.rb, line 20 def install(manifest = 'manifest.yml') unless File.exist? manifest logger.fatal { "Manifest file '#{manifest}' does not exist." } return false end collection.load_manifest manifest result = options[:dryrun] ? collection.install? : collection.install msg = install_message(result, options[:dryrun]) result ? logger.info(msg) : logger.error(msg) result end
logger()
click to toggle source
Logger instance to use. @return [Logger] logger instance
# File lib/config_curator/cli.rb, line 43 def logger @logger ||= Logger.new($stdout).tap do |log| log.progname = 'curate' log.formatter = proc do |severity, _, _, msg| "#{severity} -- #{msg}\n" end log.level = log_level(options) end end
Private Instance Methods
install_message(result, dryrun)
click to toggle source
# File lib/config_curator/cli.rb, line 68 def install_message(result, dryrun) "Install #{'simulation ' if dryrun}" + \ if result 'completed without error.' elsif result.nil? 'failed.' else 'failed. No changes were made.' end end
log_level(options)
click to toggle source
# File lib/config_curator/cli.rb, line 56 def log_level(options) if options[:debug] Logger::DEBUG elsif options[:verbose] Logger::INFO elsif options[:quiet] Logger::FATAL else Logger::WARN end end