#!/usr/bin/env ruby 
require_relative 'helper.rb'
require_relative 'generate.rb'
require_relative 'documentation_generator.rb'
require 'Ifd_Automation/version'

@features_dir = File.join(FileUtils.pwd, "project")
@source_dir = File.join(File.dirname(__FILE__), '..', 'project')

search_string = ARGV.shift
case search_string
  when /version/
    puts IfdAutomation::VERSION
  when /gen/
    ifd_automation_scaffold
  when /ls/
    ORDERED_KINDS = %w[Given When Then]
    heading = 'All Ifd_Automation steps'

# collect
    steps_glob = File.expand_path('../../lib/Ifd_Automation/*_steps.rb', __FILE__)
    step_names = `cat #{steps_glob}`.split($/).select { |line| line =~ /^\s*(Given|When|Then)/ }

# format
#     step_names.map! do |step|
      # DocumentationGenerator::StepDefinition.try_and_parse(step)
      # p step
    # end

# sort
#     step_names = step_names.sort_by do |step|
#       step =~ /^(\w+)(.*)/
#       [ORDERED_KINDS.index($1), $2]
#     end

# Output
    puts "\e[4;34m\n# #{heading}\e[0m" # blue underline
    puts step_names
  else
    print_help
end



