# File lib/daemons/cmdline.rb, line 8 def initialize(controller) @controller = controller @options = {} @opts = OptionParser.new do |opts| #opts.banner = "Usage: example.rb [options]" opts.banner = "" # Boolean switch. # opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| # @options[:verbose] = v # end opts.on("-t", "--ontop", "Stay on top (does not daemonize)") do |t| @options[:ontop] = t end opts.on("-f", "--force", "Force operation") do |t| @options[:force] = t end #opts.separator "" #opts.separator "Specific options:" opts.separator "" opts.separator "Common options:" # No argument, shows at tail. This will print an options summary. # Try it and see! opts.on_tail("-h", "--help", "Show this message") do #puts opts #@usage = controller.print_usage() exit end # Another typical switch to print the version. opts.on_tail("--version", "Show version") do puts "daemons version #{Daemons::VERSION}" exit end end begin @usage = @opts.to_s rescue ::Exception # work around a bug in ruby 1.9 @usage = -t, --ontop Stay on top (does not daemonize) -f, --force Force operation Common options: -h, --help Show this message --version Show version end end
Generated with the Darkfish Rdoc Generator 2.