class WTBuildHelpers::TeamCity::OptionsParser

Public Class Methods

parse(options) click to toggle source
# 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.slice!("https://")
            url.insert(0, "https://")
            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