Module: UberDoc::Options

Defined in:
lib/uberdoc/options.rb

Class Method Summary collapse

Class Method Details

.parse(args, show_help = false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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