Sha256: bdcf4077d5437996989d08e020db23938753fa7a48ac6beea039411003036ba5
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
#!/usr/bin/env ruby require "optparse" require_relative "../lib/commands/validate_schema" def print_usage! $stderr.puts "Usage: validate-schema <schema> <data>, ..." $stderr.puts " validate-schema -d <data>, ..." end command = Commands::ValidateSchema.new parser = OptionParser.new { |opts| opts.on("-d", "--detect", "Detect schema from $schema") do command.detect = true # mix in common schemas for convenience command.extra_schemas += ["schema.json", "hyper-schema.json"]. map { |f| File.expand_path(f, __FILE__ + "/../../schemas") } end opts.on("-s", "--schema SCHEMA", "Additional schema to use for references") do |s| command.extra_schemas << s end opts.on("-f", "--fail-fast", "Abort after encountering the first validation error") do |s| command.fail_fast = true end } parser.parse! success = command.run(ARGV.dup) if success command.messages.each { |m| $stdout.puts(m) } elsif !command.errors.empty? command.errors.each { |e| $stderr.puts(e) } exit(1) else print_usage! exit(1) end
Version data entries
5 entries across 5 versions & 2 rubygems