Class: WTBuildHelpers::TeamCity::OptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/teamcity.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
# File 'lib/teamcity.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("-s", "--url URL", "Specify the URL for TeamCity") do |url|
            url.slice!("http://")
            url.insert(0, "http://")
            args.url = url
        end
        
        opts.on("-u", "--username USERNAME", "Specify the user to connecto to TeamCity") do |username|
            args.username = username
        end
        
        opts.on("-p", "--password PASSWORD", "Specify the password to connect to TeamCity") do |password|
            args.password = password
        end
        
        opts.on("-t", "--build_type BUILD_TYPE", "The build_type_id for the running build from TeamCity") do |build_type_id|
            args.build_type_id = build_type_id
        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