Sha256: 29b918e0779da6ba57c33fe5299c07b2d3faf42cb96e50c939443fb5d3e8a107

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'swagger/diff'

options = {}
OptionParser.new do |opts|
  opts.banner = 'Usage: swagger-diff [options] <old> <new>'

  opts.on('-c', '--changes',
          'Generate a list of changes between <new>',
          'and <old>') do |c|
    options[:changes] = c
  end

  opts.on('-i', '--incompatibilities',
          'Checks <new> for backwards-compatibility',
          'with <old>. If <new> is incompatible, a',
          'list of incompatibilities will be printed.') do |i|
    options[:incompatibilities] = i
  end

  opts.on_tail('-h', '--help', 'This message') do
    puts opts
    exit
  end

  opts.on_tail('-v', '--version', 'Display the version') do
    puts Swagger::Diff::VERSION
    exit
  end

  options[:help] = opts
end.parse!

if ARGV.length == 2
  diff = Swagger::Diff::Diff.new(ARGV[0], ARGV[1])

  if options[:changes]
    puts diff.changes_message
  else
    unless diff.compatible?
      puts diff.incompatibilities_message
      exit 1
    end
  end
else
  puts options[:help]
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
swagger-diff-2.0.0 exe/swagger-diff
swagger-diff-1.1.2 exe/swagger-diff
swagger-diff-1.1.1 exe/swagger-diff
swagger-diff-1.1.0 exe/swagger-diff