80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
# File 'lib/cucumber/cli/options.rb', line 80
def parse!(args)
@args = args
@expanded_args = @args.dup
@args.extend(::OptionParser::Arguable)
@args.options do |opts|
opts.banner = ["Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+", "",
"Examples:",
"cucumber examples/i18n/en/features",
"cucumber --language it examples/i18n/it/features/somma.feature:6:98:113",
"cucumber -s -i http://rubyurl.com/eeCl", "", "",
].join("\n")
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
"Require files before executing the features. If this",
"option is not specified, all *.rb files that are",
"siblings or below the features will be loaded auto-",
"matically. Automatic loading is disabled when this",
"option is specified, and all loading becomes explicit.",
"Files under directories named \"support\" are always",
"loaded first.",
"This option can be specified multiple times.") do |v|
@options[:require] << v
end
opts.on("-l LANG", "--language LANG",
"Specify language for features (Default: #{@options[:lang]})",
%{Run with "--language help" to see all languages},
%{Run with "--language LANG help" to list keywords for LANG}) do |v|
if v == 'help'
list_languages_and_exit
elsif args==['help'] list_keywords_and_exit(v)
else
@options[:lang] = v
end
end
opts.on("-f FORMAT", "--format FORMAT",
"How to format features (Default: pretty). Available formats:",
*FORMAT_HELP) do |v|
@options[:formats] << [v, @out_stream]
end
opts.on("-o", "--out [FILE|DIR]",
"Write output to a file/directory instead of STDOUT. This option",
"applies to the previously specified --format, or the",
"default format if no format is specified. Check the specific",
"formatter's docs to see whether to pass a file or a dir.") do |v|
@options[:formats] << ['pretty', nil] if @options[:formats].empty?
@options[:formats][-1][1] = v
end
opts.on("-t TAGS", "--tags TAGS",
"Only execute the features or scenarios with the specified tags.",
"TAGS must be comma-separated without spaces. They can be",
"specified with or without the @ prefix. Example: --tags dev\n",
"Negative tags: Prefix tags with ~ to exclude features or scenarios",
"having that tag.\n",
"Limit WIP: Positive tags can be given a threshold to limit the",
"number of occurrences. Example: --tags qa:3 will fail if there",
"are more than 3 occurrences of the @qa tag.") do |v|
include_tags, exclude_tags = *parse_tags(v)
@options[:include_tags].merge!(include_tags)
@options[:exclude_tags].merge!(exclude_tags)
end
opts.on("-n NAME", "--name NAME",
"Only execute the feature elements which match part of the given name.",
"If this option is given more than once, it will match against all the",
"given names.") do |v|
@options[:name_regexps] << /#{v}/
end
opts.on("-e", "--exclude PATTERN", "Don't run feature files or require ruby files matching PATTERN") do |v|
@options[:excludes] << Regexp.new(v)
end
opts.on(PROFILE_SHORT_FLAG, "#{PROFILE_LONG_FLAG} PROFILE",
"Pull commandline arguments from cucumber.yml which can be defined as",
"strings or arrays. When a 'default' profile is defined and no profile",
"is specified it is always used. (Unless disabled, see -P below.)",
"When feature files are defined in a profile and on the command line",
"then only the ones from the command line are used.") do |v|
@profiles << v
end
opts.on(NO_PROFILE_SHORT_FLAG, NO_PROFILE_LONG_FLAG,
"Disables all profile laoding to avoid using the 'default' profile.") do |v|
@disable_profile_loading = true
end
opts.on("-c", "--[no-]color",
"Whether or not to use ANSI color in the output. Cucumber decides",
"based on your platform and the output destination if not specified.") do |v|
Term::ANSIColor.coloring = v
end
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
"This also omits the loading of your support/env.rb file if it exists.",
"Implies --quiet.") do
@options[:dry_run] = true
@quiet = true
end
opts.on("-a", "--autoformat DIRECTORY",
"Reformats (pretty prints) feature files and write them to DIRECTORY.",
"Be careful if you choose to overwrite the originals.",
"Implies --dry-run --formatter pretty.") do |directory|
@options[:autoformat] = directory
Term::ANSIColor.coloring = false
@options[:dry_run] = true
@quiet = true
end
opts.on("-m", "--no-multiline",
"Don't print multiline strings and tables under steps.") do
@options[:no_multiline] = true
end
opts.on("-s", "--no-source",
"Don't print the file and line of the step definition with the steps.") do
@options[:source] = false
end
opts.on("-i", "--no-snippets", "Don't print snippets for pending steps.") do
@options[:snippets] = false
end
opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
@quiet = true
end
opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
Exception.cucumber_full_backtrace = true
end
opts.on("-S", "--strict", "Fail if there are any undefined steps.") do
@options[:strict] = true
end
opts.on("-w", "--wip", "Fail if there are any passing scenarios.") do
@options[:wip] = true
end
opts.on("-v", "--verbose", "Show the files and features loaded.") do
@options[:verbose] = true
end
opts.on("-g", "--guess", "Guess best match for Ambiguous steps.") do
@options[:guess] = true
end
opts.on("-x", "--expand", "Expand Scenario Outline Tables in output.") do
@options[:expand] = true
end
opts.on("--no-diff", "Disable diff output on failing expectations.") do
@options[:diff_enabled] = false
end
opts.on(DRB_FLAG, "Run features against a DRb server. (i.e. with the spork gem)") do
@options[:drb] = true
end
opts.on_tail("--version", "Show version.") do
@out_stream.puts VERSION::STRING
Kernel.exit
end
opts.on_tail("-h", "--help", "You're looking at it.") do
@out_stream.puts opts.help
Kernel.exit
end
end.parse!
if @quiet
@options[:snippets] = @options[:source] = false
else
@options[:snippets] = true if @options[:snippets].nil?
@options[:source] = true if @options[:source].nil?
end
@options[:paths] = @args.dup
merge_profiles
print_profile_information
self
end
|