module UberDoc::Options

Public Class Methods

parse(args, show_help=false) click to toggle source
# File lib/uberdoc/options.rb, line 10
def self.parse(args, show_help=false)
    
    options = OpenStruct.new
    
    options.source_directories = []
    options.verbose = false
    options.generate = false
    options.doctor = false
    options.docset = false

    parser = OptionParser.new do |opts|

        opts.banner = "Usage: uberdoc [options]"
        opts.separator ""
        opts.separator "Available Options:"
        
        opts.on("-d", "--directory DIRECTORY",
                "Looks for all UberDocMe files in the specified directory")  do |dir|
            options.source_directories << dir
        end

        opts.on("-v", "--verbose",
                "Verbosely print all commands and their output") do |verbose|
            options.verbose = true
        end

        opts.on("-g", "--generate",
                "Generate the base UberDocMe template file in the current directory") do |gen|
            options.generate = true
        end

        opts.on("--doctor",
                "Diagnoses the system to find missing dependencies") do |doc|
            options.doctor = true
        end

        opts.on("--docset",
                "Generate Docsets as well as HTML docs") do |docset|
            options.docset = true
        end

    end # OptionParser

    parser.parse!(args)

    if show_help
        puts parser.help
    end

    return options

end