Parent

Methods

Daemons::Optparse

Attributes

usage[R]

Public Class Methods

new(controller) click to toggle source
# File lib/daemons/cmdline.rb, line 8
    def initialize(controller)
      @controller = controller
      @options = {}
      
      @opts = OptionParser.new do |opts|
        opts.banner = ""
        
#         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.on("-n", "--no_wait", "Do not wait for processes to stop") do |t|
          @options[:no_wait] = 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
        opts.on_tail("-h", "--help", "Show this message") do
          #puts opts
          #@usage = 
          controller.print_usage()
          
          exit
        end

        # 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            -n, --no_wait                    Do not wait for processes to stop        Common options:            -h, --help                       Show this message                --version                    Show version
      end
    end

Public Instance Methods

parse(args) click to toggle source

Return a hash describing the options.

# File lib/daemons/cmdline.rb, line 73
def parse(args)
  # The options specified on the command line will be collected in *options*.
  # We set default values here.
  #options = {}
  
  
  ##pp args
  @opts.parse(args)
  
  return @options
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.