Parent

Methods

Daemons::Optparse

Attributes

usage[R]

Public Class Methods

new(controller) click to toggle source
    # 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 = ""
14:         
15: #         opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
16: #           @options[:verbose] = v
17: #         end
18:         
19:         opts.on("-t", "--ontop", "Stay on top (does not daemonize)") do |t|
20:           @options[:ontop] = t
21:         end
22:         
23:         opts.on("-f", "--force", "Force operation") do |t|
24:           @options[:force] = t
25:         end
26:         
27:         opts.on("-n", "--no_wait", "Do not wait for processes to stop") do |t|
28:           @options[:no_wait] = t
29:         end
30:         
31:         #opts.separator ""
32:         #opts.separator "Specific options:"
33: 
34:         
35:         opts.separator ""
36:         opts.separator "Common options:"
37: 
38:         # No argument, shows at tail.  This will print an options summary
39:         opts.on_tail("-h", "--help", "Show this message") do
40:           #puts opts
41:           #@usage = 
42:           controller.print_usage()
43:           
44:           exit
45:         end
46: 
47:         # Switch to print the version.
48:         opts.on_tail("--version", "Show version") do
49:           puts "daemons version #{Daemons::VERSION}"
50:           exit
51:         end
52:       end  
53:       
54:       begin
55:         @usage = @opts.to_s
56:       rescue ::Exception # work around a bug in ruby 1.9
57:         @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
58:       end
59:     end

Public Instance Methods

parse(args) click to toggle source

Return a hash describing the options.

    # File lib/daemons/cmdline.rb, line 73
73:     def parse(args)
74:       # The options specified on the command line will be collected in *options*.
75:       # We set default values here.
76:       #options = {}
77:       
78:       
79:       ##pp args
80:       @opts.parse(args)
81:       
82:       return @options
83:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.