Sha256: ba712bd83aadbda054756182cee64a17371f9c71aed54bc0d09ecfb2b8e9ad3c

Contents?: true

Size: 909 Bytes

Versions: 1

Compression:

Stored size: 909 Bytes

Contents

require 'optparse'

module JunitModel
  module CLI
    # The options to be used throughout the CLI Module
    class Options
      attr_accessor :files, :output_path
      def initialize
        self.files = []
        self.output_path = './merged_tests.xml'
      end
    end

    # Parse CLI::Options from ARGV
    class Parser
      def self.parse(argv)
        options = Options.new
        opt_parser = OptionParser.new do |opts|
          opts.banner = 'Usage: example.rb [options]'

          opts.on('-o', '--output OUTPUT', String, 'Output') do |n|
            options.output_path = n
          end

          opts.on('-h', '--help', 'Prints this help') do
            puts opts
            exit
          end
        end

        opt_parser.order(argv) do |file|
          options.files << file unless file.nil?
        end

        opt_parser.parse(argv)
        options
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
junit_model-0.1.1 lib/junit_model/cli/cli_parser.rb