def parse_options(argv:)
      input_path = nil
      benchmark_time = 30
      benchmark_warmup = 5
      lines_multipliers = [1]
      verbose = false

      OptionParser.new do |parser|
        parser.banner = 'Usage: bin/benchmark [file.csv] [options]'
        parser.default_argv = argv

        parser.on('--csv=[file1.csv]', String, 'CSV file(s)') do |value|
          input_path = value
        end

        parser.on('--[no-]verbose', 'Verbose output') do |value|
          verbose = value
        end

        parser.on('--lines-multipliers=[1,10,50]', Array, 'Multiply the rows in the CSV file (default: 1)') do |value|
          lines_multipliers = value.map do |v|
            Integer(v).tap do |int|
              unless int >= 1
                raise(ArgumentError, '--lines-multiplier must be 1 or greater')
              end
            end
          end
        end

        parser.on('--time=[30]', String, 'Benchmark time (default: 30)') do |value|
          benchmark_time = Integer(value)
        end

        parser.on('--warmup=[30]', String, 'Benchmark warmup (default: 30)') do |value|
          benchmark_warmup = Integer(value)
        end

        parser.on('-h', '--help', 'How to use') do
          puts parser
          exit
        end

        # No argument, shows at tail. This will print an options summary.
        parser.on_tail('-h', '--help', 'Show this message') do
          puts parser
          exit
        end
      end.parse!

      {
        input_path: input_path,
        benchmark_time: benchmark_time,
        benchmark_warmup: benchmark_warmup,
        lines_multipliers: lines_multipliers,
        verbose: verbose,
      }
    end
def parse_options(argv:)
      input_path = nil
      benchmark_time = 30
      benchmark_warmup = 5
      lines_multipliers = [1]
      verbose = false

      OptionParser.new do |parser|
        parser.banner = 'Usage: bin/benchmark [file.csv] [options]'
        parser.default_argv = argv

        parser.on('--csv=[file1.csv]', String, 'CSV file(s)') do |value|
          input_path = value
        end

        parser.on('--[no-]verbose', 'Verbose output') do |value|
          verbose = value
        end

        parser.on('--lines-multipliers=[1,10,50]', Array, 'Multiply the rows in the CSV file (default: 1)') do |value|
          lines_multipliers = value.map do |v|
            Integer(v).tap do |int|
              unless int >= 1
                raise(ArgumentError, '--lines-multiplier must be 1 or greater')
              end
            end
          end
        end

        parser.on('--time=[30]', String, 'Benchmark time (default: 30)') do |value|
          benchmark_time = Integer(value)
        end

        parser.on('--warmup=[30]', String, 'Benchmark warmup (default: 30)') do |value|
          benchmark_warmup = Integer(value)
        end

        parser.on('-h', '--help', 'How to use') do
          puts parser
          exit
        end

        # No argument, shows at tail. This will print an options summary.
        parser.on_tail('-h', '--help', 'Show this message') do
          puts parser
          exit
        end
      end.parse!

      {
        input_path: input_path,
        benchmark_time: benchmark_time,
        benchmark_warmup: benchmark_warmup,
        lines_multipliers: lines_multipliers,
        verbose: verbose,
      }
    end
Parse command line arguments and return options
 @param [Array<String>] argv the command lines arguments
 @return [Hash] the command line options