bin/spreewald in spreewald-1.5.5 vs bin/spreewald in spreewald-1.6.0

- old
+ new

@@ -1,31 +1,72 @@ #!/usr/bin/env ruby -require File.expand_path('../../support/documentation_generator', __FILE__) +require File.expand_path('../../support/step_manager', __FILE__) +require File.expand_path('../../support/paths_manager', __FILE__) -ORDERED_KINDS = %w[Given When Then] -heading = 'All Spreewald steps' -search_string = ARGV.shift +def announce(text) + puts "\e[4;34m\n# #{text}\e[0m" # blue underline +end -# collect -steps_glob = File.expand_path('../../lib/spreewald/*_steps.rb', __FILE__) -step_names = `cat #{steps_glob}`.split($/).select { |line| line =~ /^\s*(Given|When|Then)/ } +case (option = ARGV.shift) +when '--selectors', '-s' + search = ARGV.join(' ') + manager = PathsManager.new('features/support/selectors.rb') -# format -step_names.map! do |step| - DocumentationGenerator::StepDefinition.try_and_parse(step).format_definition -end + heading = 'All selectors from features/support/selectors.rb' + heading << " containing '#{search}'" if search -# sort -step_names = step_names.sort_by do |step| - step =~ /^(\w+)(.*)/ - [ORDERED_KINDS.index($1), $2] -end + announce heading + puts manager.paths(search) -# filter -if search_string - heading << " containing '#{search_string}'" - step_names = step_names.grep Regexp.new(search_string) +when '--paths', '-p' + search = ARGV.join(' ') + manager = PathsManager.new('features/support/paths.rb') + + heading = 'All paths from features/support/paths.rb' + heading << " containing '#{search}'" if search + + announce heading + puts manager.paths(search) + +when '--help', '-h' + + puts <<-HELP +USAGE: + spreewald [SEARCH] + List all Spreewald steps + all steps from the current project (run from + project root). Optionally filtered by SEARCH. + + spreewald --paths [SEARCH] + List all paths from features/support/paths.rb, optionally filtered by SEARCH + Alias -p + + spreewald --selectors [SEARCH] + List all paths from features/support/paths.rb, optionally filtered by SEARCH + Alias -s + + spreewald --version + Print Spreewald's version and exit + Alias -v + + spreewald --help + Print this help and exit + Alias -h + + HELP + +when '--version', '-v' + require File.expand_path('../../lib/spreewald_support/version', __FILE__) + puts "Spreewald #{ Spreewald::VERSION }" + +else + search = [option].concat(ARGV).join(' ') + spreewald_steps = File.expand_path('../../lib/spreewald', __FILE__) + project_steps = 'features/step_definitions' + manager = StepManager.new(spreewald_steps, project_steps) + + heading = 'All Spreewald steps' + heading << " containing '#{search}'" if search + + announce heading + puts manager.steps(search).map(&:to_s) end -# Output -puts "\e[4;34m\n# #{heading}\e[0m" # blue underline -puts step_names