Class: Cuporter::CLI::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/cuporter/cli/options.rb

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



9
10
11
# File 'lib/cuporter/cli/options.rb', line 9

def self.[](key)
  self.options[key]
end

.optionsObject



13
14
15
16
# File 'lib/cuporter/cli/options.rb', line 13

def self.options
  self.parse unless @options
  @options
end

.parseObject



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
62
63
64
65
66
# File 'lib/cuporter/cli/options.rb', line 18

def self.parse
  @options = {}
  OptionParser.new(ARGV.dup) do |opts|
    opts.banner = "Usage: cuporter [options]\n\n"

    @options[:input_dir] = "features/**/*.feature"
    opts.on("-i", "--in DIR", "directory of *.feature files\n\t\t\t\t\tDefault: features/**/*.feature\n\n") do |i|
      @options[:input_dir] = "#{i}/**/*.feature"
    end

    opts.on("-I", "--input-file FILE", "full file name with extension: 'path/to/file.feature'\n\n") do |file|
      @options[:input_file] = file
    end
    opts.on("-o", "--out FILE", "Output file path\n\n") do |o|
      full_path = File.expand_path(o)
      path = full_path.split(File::SEPARATOR)
      file = path.pop
      FileUtils.makedirs(path.join(File::SEPARATOR))

      @options[:output] = full_path
    end
    @options[:format] = "text"
    opts.on("-f", "--format [pretty|html|csv]", "Output format\n\t\t\t\t\tDefault: pretty text\n\n") do |f|
      @options[:format] = f
    end

    opts.on("-n", "--numbers", "number scenarios and examples\n\n") do |n|
      @options[:numbers] = n
    end

    @options[:tags] = []
    opts.on("-t", "--tags TAG_EXPRESSION", "Filter on tags for name report.\n\t\t\t\t\tTAG_EXPRESSION rules: see '$ cucumber --help' and http://github.com/aslakhellesoy/cucumber/wiki/Tags\n\n") do |t|
      @options[:tags] << t
    end

    @options[:report] = "tag"
    opts.on("-r", "--report [tag|name]", "type of report\n\t\t\t\t\tDefault: tag\n\n") do |r|
      @options[:report] = r
    end

    @options[:title] = "Cucumber Scenario Inventory"
    opts.on("-T", "--title STRING", "title of name report\n\t\t\t\t\tDefault: 'Cucumber Scenario Inventory'\n\n") do |title|
      @options[:title] = title
    end

  end.parse!


end