Sha256: 6e71aa07dca5ce0b940d12109561bc29a329bc81531c889ce0f7c6556715e00e

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

#!/usr/bin/env ruby
$VERBOSE=nil # Shut up JRuby warnings on Travis
$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 |v|
    options[:include_source] = v
  end
  opts.on("--[no-]ast", "Don't print ast messages") do |v|
    options[:include_gherkin_document] = v
  end
  opts.on("--[no-]pickles", "Don't print pickle messages") do |v|
    options[:include_pickles] = v
  end
  opts.on("--predictable-ids", "Generate incrementing ids rather than UUIDs") do |v|
    options[:id_generator] = Cucumber::Messages::IdGenerator::Incrementing.new if v
  end
end.parse!

def process_messages(messages, options)
  messages.each do |message|
    STDOUT.write(JSON.fast_generate(message))
    STDOUT.write("\n")
  end
end

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

process_messages(messages, options)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber-gherkin-19.0.3 bin/gherkin
cucumber-gherkin-19.0.2 bin/gherkin
cucumber-gherkin-19.0.1 bin/gherkin
cucumber-gherkin-19.0.0 bin/gherkin