Sha256: b1cc91b6a3d0dc088d87b7730bc26173b053e38958e0369dca46fb9f4e3ee1cb

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby

$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

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

process_messages(messages, options)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-gherkin-29.0.0 bin/gherkin