lib/cucumber/cli/options.rb in casecumber-1.0.2.1 vs lib/cucumber/cli/options.rb in casecumber-1.2.1.cb2
- old
+ new
@@ -7,14 +7,10 @@
class Options
INDENT = ' ' * 53
BUILTIN_FORMATS = {
'html' => ['Cucumber::Formatter::Html', 'Generates a nice looking HTML report.'],
'pretty' => ['Cucumber::Formatter::Pretty', 'Prints the feature as is - in colours.'],
- 'pdf' => ['Cucumber::Formatter::Pdf', "Generates a PDF report. You need to have the\n" +
- "#{INDENT}prawn gem installed. Will pick up logo from\n" +
- "#{INDENT}features/support/logo.png or\n" +
- "#{INDENT}features/support/logo.jpg if present."],
'progress' => ['Cucumber::Formatter::Progress', 'Prints one character per scenario.'],
'rerun' => ['Cucumber::Formatter::Rerun', 'Prints failing files with line numbers.'],
'usage' => ['Cucumber::Formatter::Usage', "Prints where step definitions are used.\n" +
"#{INDENT}The slowest step definitions (with duration) are\n" +
"#{INDENT}listed first. If --dry-run is used the duration\n" +
@@ -40,16 +36,20 @@
"foo/bar_zap.rb. You can place the file with this relative",
"path underneath your features/support directory or anywhere",
"on Ruby's LOAD_PATH, for example in a Ruby gem."
]
DRB_FLAG = '--drb'
+ DRB_OPTIONAL_FLAG = '--[no-]drb'
PROFILE_SHORT_FLAG = '-p'
NO_PROFILE_SHORT_FLAG = '-P'
PROFILE_LONG_FLAG = '--profile'
NO_PROFILE_LONG_FLAG = '--no-profile'
+ OPTIONS_WITH_ARGS = ['-r', '--require', '--i18n', '-f', '--format', '-o', '--out',
+ '-t', '--tags', '-n', '--name', '-e', '--exclude',
+ PROFILE_SHORT_FLAG, PROFILE_LONG_FLAG,
+ '-a', '--autoformat', '-l', '--lines', '--port']
-
def self.parse(args, out_stream, error_stream, options = {})
new(out_stream, error_stream, options).parse!(args)
end
def initialize(out_stream = STDOUT, error_stream = STDERR, options = {})
@@ -75,19 +75,35 @@
def expanded_args_without_drb
return @expanded_args_without_drb if @expanded_args_without_drb
@expanded_args_without_drb = (
previous_flag_was_profile = false
+ previous_flag_requires_arg = false
+
@expanded_args.reject do |arg|
+ # ignore profiles
if previous_flag_was_profile
previous_flag_was_profile = false
next true
end
if [PROFILE_SHORT_FLAG, PROFILE_LONG_FLAG].include?(arg)
previous_flag_was_profile = true
next true
end
+
+ # accept all options which requires arguments
+ # and don't try to look @overridden_paths in it's arguments!
+ if previous_flag_requires_arg
+ previous_flag_requires_arg = false
+ next false
+ end
+ if OPTIONS_WITH_ARGS.include?(arg)
+ previous_flag_requires_arg = true
+ next false
+ end
+
+ # ignore --drb flag and overridden features paths
arg == DRB_FLAG || @overridden_paths.include?(arg)
end
)
@expanded_args_without_drb.push("--no-profile") unless @expanded_args_without_drb.include?(NO_PROFILE_LONG_FLAG) || @expanded_args_without_drb.include?(NO_PROFILE_SHORT_FLAG)
@@ -193,22 +209,22 @@
@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
+ Cucumber::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.") do
@options[:dry_run] = true
end
opts.on("-a", "--autoformat DIR",
"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|
+ "Implies --dry-run --format pretty.") do |directory|
@options[:autoformat] = directory
- Term::ANSIColor.coloring = false
+ Cucumber::Term::ANSIColor.coloring = false
@options[:dry_run] = true
@quiet = true
end
opts.on("-m", "--no-multiline",
@@ -244,14 +260,17 @@
@options[:lines] = lines
end
opts.on("-x", "--expand", "Expand Scenario Outline Tables in output.") do
@options[:expand] = true
end
- opts.on(DRB_FLAG, "Run features against a DRb server. (i.e. with the spork gem)") do
- @options[:drb] = true
+ opts.on(DRB_OPTIONAL_FLAG, "Run features against a DRb server. (i.e. with the spork gem)") do |drb|
+ @options[:drb] = drb
end
opts.on("--port PORT", "Specify DRb port. Ignored without --drb") do |port|
@options[:drb_port] = port
+ end
+ opts.on("--dotcucumber DIR", "Write metadata to DIR") do |dir|
+ @options[:dotcucumber] = dir
end
opts.on_tail("--version", "Show version.") do
@out_stream.puts Cucumber::VERSION
Kernel.exit(0)
end