Class: FTest::CLI::ArgvParser

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, options) ⇒ ArgvParser

Returns a new instance of ArgvParser.



123
124
125
126
# File 'lib/ftest/cli.rb', line 123

def initialize argv, options
  @argv = argv
  @options = options
end

Class Method Details

.call(argv) ⇒ Object



116
117
118
119
120
121
# File 'lib/ftest/cli.rb', line 116

def self.call argv
  options = Options.build
  parser = ArgvParser.new argv, options
  parser.()
  options
end

Instance Method Details

#add_pathsObject



133
134
135
136
137
138
# File 'lib/ftest/cli.rb', line 133

def add_paths
  @argv << "tests" if @argv.empty?
  @argv.each do |path|
    @options.add_path path
  end
end

#callObject



128
129
130
131
# File 'lib/ftest/cli.rb', line 128

def call
  parse_options
  add_paths
end

#parse_optionsObject



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/ftest/cli.rb', line 140

def parse_options
  OptionParser.new do |opts|
    opts.banner = "Usage: \#{program_name} [options] [PATH1] [PATH2] \u2026 [PATHn]\n\nIf no PATH(s) are specified, ./tests is assumed\n\n    BANNER\n\n    opts.on \"-b\", \"--full-backtrace\", \"Do not filter assertion stack traces\" do\n      @options.full_backtrace\n    end\n\n    opts.on \"-f\", \"--fail-fast\", \"When any test script fails, exit immediately\" do\n      @options.fail_fast\n    end\n\n    opts.on \"-h\", \"--help\", \"Print this message and exit successfully\" do\n      puts opts\n      exit 0\n    end\n\n    opts.on \"-m\", \"--monkeypatch\", \"Turn on monkeypatching (equivalent to `require \\\"ftest/script\\\"'\" do\n      require \"ftest/script\"\n    end\n\n    opts.on \"-n\", \"--num=COUNT\", \"Max number of sub processes to run concurrently\" do |num|\n      @options.child_count = num\n    end\n\n    opts.on \"-q\", \"--quiet\", \"Reduces log verbosity\" do\n      @options.quiet\n    end\n\n    opts.on \"-r\", \"--reverse-traces\", \"Reverse the order of stack traces\" do\n      @options.reverse_backtraces\n    end\n\n    opts.on \"-V\", \"--version\", \"Print version and exit successfully\" do\n      spec = Gem.loaded_specs[\"ftest\"]\n      version = if spec then spec.version else \"(local)\" end\n      puts \"Version: \#{version}\"\n      exit 0\n    end\n\n    opts.on \"-v\", \"--verbose\", \"Increases log verbosity\" do\n      @options.verbose\n    end\n  end.parse! @argv\nend\n"

#program_nameObject



191
192
193
# File 'lib/ftest/cli.rb', line 191

def program_name
  File.basename $PROGRAM_NAME
end