Class: NG1BuildHelpers::CircleCI::OptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/circleci/circleci.rb

Class Method Summary collapse

Class Method Details

.parse(options) ⇒ Object



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
# File 'lib/circleci/circleci.rb', line 17

def self.parse(options)
    args = Options.new()
    args.export = false
       
    opt_parser = OptionParser.new do |opts|
        opts.banner = "Usage: #{__FILE__} [options]"
    
        opts.on("-u", "--url URL", "Specify the URL for CircleCI instance") do |url|
            args.url = url
        end
        
        opts.on("-c", "--company COMPANY", "Specify the company for CircleCI") do |company|
            args.company = company
        end

        opts.on("-p", "--project PROJECT", "Specify the project for CircleCI") do |project|
            args.project = project
        end

        opts.on("-b", "--branch BRANCH", "Specify the branch for CircleCI") do |branch|
            args.branch = branch
        end

        opts.on("-t", "--token TOKEN", "Specify the token for CircleCI") do |token|
            args.token = token
        end

        opts.on("-e", "--export", "Output range for use as a parameter to the 'export' bash command") do 
            args.export = true
        end

        opts.on_tail("-h", "--help", "Show this message") do
            puts opts
            exit
        end
    end

    opt_parser.parse!(options)
    return args   
end