Sha256: 89293707c237c85a4656eafb67c52f23c6b1a2f225cd8c1e40477a618e00efdb

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

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

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-gherkin-30.0.0 bin/gherkin