# File lib/daemons/cmdline.rb, line 8
8: def initialize(controller)
9: @controller = controller
10: @options = {}
11:
12: @opts = OptionParser.new do |opts|
13: #opts.banner = "Usage: example.rb [options]"
14: opts.banner = ""
15:
16: # Boolean switch.
17: # opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
18: # @options[:verbose] = v
19: # end
20:
21: opts.on("-t", "--ontop", "Stay on top (does not daemonize)") do |t|
22: @options[:ontop] = t
23: end
24:
25: opts.on("-f", "--force", "Force operation") do |t|
26: @options[:force] = t
27: end
28:
29: opts.on("-n", "--no_wait", "Do not wait for processes to stop") do |t|
30: @options[:no_wait] = t
31: end
32:
33: #opts.separator ""
34: #opts.separator "Specific options:"
35:
36:
37: opts.separator ""
38: opts.separator "Common options:"
39:
40: # No argument, shows at tail. This will print an options summary.
41: # Try it and see!
42: opts.on_tail("-h", "--help", "Show this message") do
43: #puts opts
44: #@usage =
45: controller.print_usage()
46:
47: exit
48: end
49:
50: # Another typical switch to print the version.
51: opts.on_tail("--version", "Show version") do
52: puts "daemons version #{Daemons::VERSION}"
53: exit
54: end
55: end
56:
57: begin
58: @usage = @opts.to_s
59: rescue ::Exception # work around a bug in ruby 1.9
60: @usage = -t, --ontop Stay on top (does not daemonize) -f, --force Force operation -n, --no_wait Do not wait for processes to stop Common options: -h, --help Show this message --version Show version
61: end
62: end
Return a hash describing the options.
# File lib/daemons/cmdline.rb, line 76
76: def parse(args)
77: # The options specified on the command line will be collected in *options*.
78: # We set default values here.
79: #options = {}
80:
81:
82: ##pp args
83: @opts.parse(args)
84:
85: return @options
86: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.