class Object
Public Instance Methods
init_params()
click to toggle source
# File lib/configmonkey_cli/application.rb, line 102 def init_params @optparse = OptionParser.new do |opts| opts.banner = "Usage: configmonkey [options]" opts.separator(c "# Application options", :blue) opts.on("--generate-manifest", "Generates an example manifest in current directory") { @opts[:dispatch] = :generate_manifest } opts.on("-a", "--accept", "accept all defaults") { @opts[:default_accept] = true } opts.on("-b", "--bell", "dont ring a bell when asked") { @opts[:bell] = true } opts.on("-D", "--diff", "change default diff tool") {|s| @opts[:diff_tool] = s } opts.on("-f", "--fake-host HOST", "override hostname") {|s| @opts[:hostname] = s } opts.on("-i", "--in DIR", "operate from this source directory instead of pwd") {|s| @opts[:working_directory] = s } opts.on("-o", "--out DIR", "operate on this target directory instead of /") {|s| @opts[:target_directory] = s } opts.on("-l", "--log [file]", "Log changes to file, defaults to ~/.configmonkey/logs/configmonkey.log") {|s| @opts[:logfile] = s || logger_filename } opts.on("-M", "--merge", "change default merge tool") {|s| @opts[:merge_tool] = s } opts.on("-n", "--dry-run", "Simulate changes only, does not perform destructive operations") { @opts[:simulation] = true } opts.on("-y", "--yes", "accept all prompts with yes") { @opts[:default_yes] = true } opts.on( "--dev-dump-actions", "Dump actions and exit") { @opts[:dev_dump_actions] = true } # opts.on("-q", "--quiet", "Only print errors") { @opts[:quiet] = true } opts.separator("\n" << c("# General options", :blue)) opts.on("-d", "--debug [lvl=1]", Integer, "Enable debug output") {|l| @opts[:debug] = l || 1 } opts.on("-m", "--monochrome", "Don't colorize output") { @opts[:colorize] = false } opts.on("-h", "--help", "Shows this help") { @opts[:dispatch] = :help } opts.on("-v", "--version", "Shows version and other info") { @opts[:dispatch] = :info } opts.on("-z", "Do not check for updates on GitHub (with -v/--version)") { @opts[:check_for_updates] = false } end end
parse_params()
click to toggle source
# File lib/configmonkey_cli/application.rb, line 130 def parse_params @optparse.parse!(@argv) # resolve diff/merge tool @opts[:diff_tool] = find_diff_tool @opts[:merge_tool] = find_merge_tool # thor bell ENV['THOR_ASK_BELL'] = "true" if @opts[:bell] # thor no-colors ENV['NO_COLOR'] = "true" if !@opts[:colorize] # thor diff-tool ENV['THOR_DIFF'] = opts[:diff_tool] if @opts[:diff_tool] rescue OptionParser::ParseError => e abort(e.message) dispatch(:help) exit 1 end
running?()
click to toggle source
# File lib/configmonkey_cli/application.rb, line 155 def running? @running end
sync(&block)
click to toggle source
# File lib/configmonkey_cli/application.rb, line 151 def sync &block @monitor.synchronize(&block) end
to_s()
click to toggle source
# File lib/configmonkey_cli/application.rb, line 98 def to_s "#<ConfigmonkeyCli::Application @boot=#{@boot} @opts=#{@opts} @running=#{@running}>" end