lib/teaspoon/command_line.rb in teaspoon-0.8.0 vs lib/teaspoon/command_line.rb in teaspoon-0.9.0

- old
+ new

@@ -1,12 +1,12 @@ require "optparse" require "teaspoon/version" require "teaspoon/exceptions" +require "teaspoon/formatters/base" module Teaspoon class CommandLine - def initialize @options = {} @options[:files] = opt_parser.parse! require_console @@ -29,103 +29,100 @@ end protected def opts_for_general - opt :environment, - "-r", "--require FILE", - "Require Teaspoon environment file." + opt :environment, "-r", "--require FILE", + "Require Teaspoon environment file." - #opt :custom_options_file, - # "-O", "--options PATH", - # "Specify the path to a custom options file." + # opt :custom_options_file, + # "-O", "--options PATH", + # "Specify the path to a custom options file." opt :driver, "-d", "--driver DRIVER", - "Specify driver:", - " phantomjs (default)", - " selenium" + "Specify driver:", + " phantomjs (default)", + " selenium", + " capybara_webkit" opt :driver_options, "--driver-options OPTIONS", - "Specify driver-specific options to pass into the driver.", - " e.g. \"--ssl-protocol=any --ssl-certificates-path=/path/to/certs\".", - " Driver options are only supported with phantomjs." + "Specify driver-specific options to pass into the driver.", + " e.g. \"--ssl-protocol=any --ssl-certificates-path=/path/to/certs\".", + " Driver options are only supported with phantomjs." opt :driver_timeout, "--driver-timeout SECONDS", - "Sets the timeout for the driver to wait before exiting." + "Sets the timeout for the driver to wait before exiting." opt :server, "--server SERVER", - "Sets server to use with Rack.", - " e.g. webrick, thin" + "Sets server to use with Rack.", + " e.g. webrick, thin" opt :server_port, "--server-port PORT", - "Sets the server to use a specific port." + "Sets the server to use a specific port." opt :server_timeout, "--server-timeout SECONDS", - "Sets the timeout that the server must start within." + "Sets the timeout that the server must start within." opt :fail_fast, "-F", "--[no-]fail-fast", - "Abort after the first failing suite." + "Abort after the first failing suite." end def opts_for_filtering separator("Filtering") opt :suite, "-s", "--suite SUITE", - "Focus to a specific suite." + "Focus to a specific suite." opt :filter, "-g", "--filter FILTER", - "Filter tests matching a specific filter." + "Filter tests matching a specific filter." end def opts_for_output separator("Output") opt :suppress_log, "-q", "--[no-]suppress-log", - "Suppress logs coming from console[log/debug/error]." + "Suppress logs coming from console[log/debug/error]." opt :color, "-c", "--[no-]color", - "Enable/Disable color output." + "Enable/Disable color output." opt :export, "-e", "--export [OUTPUT_PATH]", - "Exports the test suite as the full HTML (requires wget)." + "Exports the test suite as the full HTML (requires wget)." opt :formatters, "-f", "--format FORMATTERS", - "Specify formatters (comma separated)", - " dot (default) - dots", - " documentation - descriptive documentation", - " clean - like dots but doesn't log re-run commands", - " json - json formatter (raw teaspoon)", - " junit - junit compatible formatter", - " pride - yay rainbows!", - " snowday - makes you feel warm inside", - " swayze_or_oprah - quote from either Patrick Swayze or Oprah Winfrey", - " tap - test anything protocol formatter", - " tap_y - tap_yaml, format used by tapout", - " teamcity - teamcity compatible formatter" + "Specify formatters (comma separated)", + *Teaspoon::Formatters.known_formatters.map(&:cli_help) end def opts_for_coverage separator("Coverage") opt :use_coverage, "-C", "--coverage CONFIG_NAME", - "Generate coverage reports using a pre-defined coverage configuration." + "Generate coverage reports using a pre-defined coverage configuration." end def opts_for_utility separator("Utility") - @parser.on "-v", "--version", "Display the version.", proc{ STDOUT.print("#{Teaspoon::VERSION}\n"); exit } - @parser.on "-h", "--help", "You're looking at it.", proc { STDOUT.print("#{@parser}\n"); exit } + @parser.on "-v", "--version", "Display the version." do + STDOUT.print("#{Teaspoon::VERSION}\n") + exit + end + + @parser.on "-h", "--help", "You're looking at it." do + STDOUT.print("#{@parser}\n") + exit + end end private def separator(message) @parser.separator("\n **** #{message} ****\n\n") end def opt(config, *args) - @parser.on(*args, proc{ |value| @options[config] = value }) + @parser.on(*args, proc { |value| @options[config] = value }) end def require_console require "teaspoon/console" end