Sha256: 7aa78d0e02db743e38eb464f65c2133be44b85c9688e0e312447863e9a098fab

Contents?: true

Size: 1.57 KB

Versions: 5

Compression:

Stored size: 1.57 KB

Contents

#!/usr/bin/env ruby

require 'sippy_cup'
require 'getoptlong'

def usage
  puts "#{$0} [OPTS] </path/to/sippy_cup_definition.yml>"
  puts
  puts "--compile, -c  Compile the given scenario manifest to XML and PCAP"
  puts "--run, -r      Run the scenario"
  puts "--help, -h     Print this usage information"
  puts "--version, -V  Print SippyCup version"
end

opts = GetoptLong.new(
  ['--compile', '-c', GetoptLong::NO_ARGUMENT],
  ['--run', '-r', GetoptLong::NO_ARGUMENT],
  ['--help', '-h', GetoptLong::NO_ARGUMENT],
  ['--version', '-V', GetoptLong::NO_ARGUMENT]
)

compile = false
run = false
opts.each do |opt, arg|
  case opt
  when '--compile'
    compile = true
  when '--run'
    run = true
  when '--help'
    usage
    exit 0
  when '--version'
    require 'sippy_cup/version'
    puts "SippyCup version #{SippyCup::VERSION}"
    exit 0
  end
end

unless ARGV.count == 1
  puts "ERROR: Must supply the SippyCup manifest file"
  puts
  usage
  exit 1
end

manifest_path = ARGV.shift

unless File.readable? manifest_path
  puts "ERROR: Unable to read manifest file"
  puts
  usage
  exit 1
end

unless compile || run
  puts "No action (compile or run) specified. Exiting."
  usage
  exit 1
end

scenario = SippyCup::Scenario.from_manifest File.read(manifest_path), input_filename: manifest_path
if scenario.valid?
  scenario.compile! if compile
else
  $stderr.puts "Errors encountered while building the scenario!"
  puts "Step\tError Message"
  scenario.errors.each do |error|
    puts "#{error[:step]}\t#{error[:message]}"
  end
end

if run
  runner = SippyCup::Runner.new scenario
  runner.run
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sippy_cup-0.7.2 bin/sippy_cup
sippy_cup-0.7.1 bin/sippy_cup
sippy_cup-0.7.0 bin/sippy_cup
sippy_cup-0.6.0 bin/sippy_cup
sippy_cup-0.5.0 bin/sippy_cup