Sha256: b9fac08a863f90a5c0d9fa6743aa4491d3160639149fc521e2c757693ab29376

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))

require 'optparse'
require 'json'
require 'cucumber/messages'
require 'gherkin'

options = {
  include_source: true,
  include_gherkin_document: true,
  include_pickles: true,
  predictable_ids: false
}

OptionParser.new do |opts|
  opts.on('--[no-]source', "Don't print source messages") do |value|
    options[:include_source] = value
  end
  opts.on('--[no-]ast', "Don't print ast messages") do |value|
    options[:include_gherkin_document] = value
  end
  opts.on('--[no-]pickles', "Don't print pickle messages") do |value|
    options[:include_pickles] = value
  end
  opts.on('--predictable-ids', 'Generate incrementing ids rather than UUIDs') do |value|
    options[:id_generator] = Cucumber::Messages::Helpers::IdGenerator::Incrementing.new if value
  end
end.parse!

def process_messages(messages, _options)
  messages.each do |message|
    $stdout.write(message.to_json)
    $stdout.write("\n")
  end
end

messages =
  if ARGV.empty?
    # Read from $stdin
    Cucumber::Messages::Helpers::NdjsonToMessageEnumerator.new($stdin)
  else
    Gherkin.from_paths(ARGV, options)
  end

process_messages(messages, options)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber-gherkin-30.0.4 bin/gherkin
cucumber-gherkin-30.0.3 bin/gherkin
cucumber-gherkin-30.0.2 bin/gherkin
cucumber-gherkin-30.0.1 bin/gherkin