<commit_before># Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
require 'optparse'
require 'fileutils'

module Cuporter
  module CLI

    class Options

      def self.[](key)
        self.options[key]
      end

      def self.options
        unless @options
          self.parse 
          @options[:input_file_pattern] = @options.delete(:input_file) || "#{@options.delete(:input_dir)}/**/*.feature"
          @options[:root_dir] = @options[:input_file_pattern].split(File::SEPARATOR).first
          @options[:filter_args] = Cuporter::CLI::FilterArgsBuilder.new(@options.delete(:tags)).args
        end
        @options
      end

      def self.args
        @@args
      end

      def self.parse
        @@args = ARGV.dup
        @options = {}
        OptionParser.new(ARGV.dup) do |opts|
          opts.banner = "Usage: cuporter [options]\n\n"

          @options[:report] = "tag"
          opts.on("-r", "--report [tag|feature|tree]", %Q{View, or type of report.
                                         Default: "tag"
          }) do |r|
            @options[:report] = r
          end

          @options[:format] = "text"
          opts.on("-f", "--format [xml|html|csv|text]", %Q{Output format.
                                         Default: text (it's pretty, though!)
          }) do |f|
            @options[:format] = f
          end

          @options[:input_dir] = "features"
          opts.on("-i", "--input-dir DIR", %Q{Root directory of *.feature files.
                                         Default: "features"
     
                                         Used to build the glob pattern '[--in]/**/*.feature', which is really most likely
                                         "features/**/*.features" and finds all feature files anywhere under "features" or
                                         your custom root supplied with this option.
                                         Overridden by "--file-input'.
          }) do |i|
            @options[:input_dir] = i.sub(/#{File::SEPARATOR}$/,'')
          end

          opts.on("-I", "--file-input FILE", %Q{Single *.feature file.  Full name with extension, like 'path/to/file.feature.'
                                         Overrides "--input-dir" and used mostly for testing.
          }) do |file|<commit_msg>enable --report option 'name' to be subsistituted with 'feature'<commit_after># Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
require 'optparse'
require 'fileutils'

module Cuporter
  module CLI

    class Options

      def self.[](key)
        self.options[key]
      end

      def self.options
        unless @options
          self.parse 
          @options[:input_file_pattern] = @options.delete(:input_file) || "#{@options.delete(:input_dir)}/**/*.feature"
          @options[:root_dir] = @options[:input_file_pattern].split(File::SEPARATOR).first
          @options[:filter_args] = Cuporter::CLI::FilterArgsBuilder.new(@options.delete(:tags)).args
        end
        @options
      end

      def self.args
        @@args
      end

      def self.parse
        @@args = ARGV.dup
        @options = {}
        OptionParser.new(ARGV.dup) do |opts|
          opts.banner = "Usage: cuporter [options]\n\n"

          @options[:report] = "tag"
          opts.on("-r", "--report [tag|feature|tree]", %Q{View, or type of report.
                                         Default: "tag"
          }) do |r|
            @options[:report] = (r == 'name' ? 'feature' : r) 
          end

          @options[:format] = "text"
          opts.on("-f", "--format [xml|html|csv|text]", %Q{Output format.
                                         Default: text (it's pretty, though!)
          }) do |f|
            @options[:format] = f
          end

          @options[:input_dir] = "features"
          opts.on("-i", "--input-dir DIR", %Q{Root directory of *.feature files.
                                         Default: "features"
     
                                         Used to build the glob pattern '[--in]/**/*.feature', which is really most likely
                                         "features/**/*.features" and finds all feature files anywhere under "features" or
                                         your custom root supplied with this option.
                                         Overridden by "--file-input'.
          }) do |i|
            @options[:input_dir] = i.sub(/#{File::SEPARATOR}$/,'')
          end

          opts.on("-I", "--file-input FILE", %Q{Single *.feature file.  Full name with extension, like 'path/to/file.feature.'
                                         Overrides "--input-dir" and used mostly for testing.
          }) do |file|
{'fraction_non_alphanumeric': 0.13166807790008467, 'fraction_numerical': 0.001693480101608806, 'mean_word_length': 1.5132978723404256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 33, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4010137', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1203, 'n_words': 328}