Class: Telly::ArgParser

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

Constant Summary collapse

VERSION_STRING =
"
 __o_____
()/O\\___()
 `-\\\\---' TELLY
              %s!
      __\\/__
     | .... |
     | .... |
      ------
"

Class Method Summary collapse

Class Method Details

.parse_optsVoid

Parses the command line options

Returns:

  • (Void)

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
62
# File 'lib/telly/arg_parser.rb', line 20

def self.parse_opts
  options_hash = {}

  optparse = OptionParser.new do|parser|
    options_hash = {
      testrun_id: nil,
      junit_file: nil,
    }

    parser.on( '-t', '--testrun-id TESTRUN_ID', 'The testrun id' ) do |testrun_id|
      options_hash[:testrun_id] = testrun_id
    end

    parser.on( '-j', '--junit-folder JUNIT_FILE', 'Beaker junit file' ) do |junit_file|
      options_hash[:junit_file] = junit_file
    end

    parser.on( '-d', '--dry-run', 'Run without API connection to TestRail' ) do
      options_hash[:dry_run] = true
    end

    parser.on( '-h', '--help', 'Display this screen' ) do
      puts parser
      exit
    end

    parser.on( '-v', '--version', 'Report the current version number' ) do
      puts VERSION_STRING % Telly::Version::STRING
      exit
    end


    parser.parse!

    if not options_hash[:testrun_id] or not options_hash[:junit_file]
      puts "Error: Missing option(s)"
      puts parser
      exit
    end
  end

  options_hash
end