gauntlt/gauntlt

View on GitHub
bin/gauntlt

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
require 'rubygems'
require 'optimist'

$:.push File.expand_path("../../lib", __FILE__) unless $:.include?( File.expand_path("../../lib", __FILE__) )
require 'gauntlt'

opts = Optimist::options do
  version Gauntlt::VERSION
  banner <<-EOS
gauntlt is a ruggedization framework that helps you be mean to your code

Usage:
       gauntlt <path>+ [--tags TAG_EXPRESSION] [--format FORMAT]

Options:
EOS

  opt :tags, "Only execute specified tags",
      :type => String,
      :multi => true

  opt :list, "List defined attacks"
  
  opt :steps, "List the gauntlt step definitions that can be used inside of attack files"

  opt :allsteps, "List all available step definitions including aruba step definitions which help with file and parsing operations"

  opt :format, "Available formats: html, json, junit, progress",
      :type => String
  opt :outfile, "Pipe run results to file",
      :type => String
end

opts[:path] = if ARGV.empty?
  "./**/*.attack"
else
  ARGV.join(" ")
end

if opts[:list]
  attack_list = Gauntlt.attacks.map{|s| "  #{s}"}.join("\n")
  puts "Defined attacks: #{}"
  puts attack_list
elsif opts[:steps]
  all_step_defs = Gauntlt.stepdefs( opts[:path], opts[:tags].join(',') )
  puts all_step_defs[:gauntlt].sort
elsif opts[:allsteps]
  all_step_defs = Gauntlt.stepdefs( opts[:path], opts[:tags].join(',') )
  puts "File and output parsing steps (using Aruba)"
  puts all_step_defs[:aruba].sort
  puts "\nGauntlt Attack Steps"
  puts all_step_defs[:gauntlt].sort
else
  Gauntlt.attack( opts[:path], opts[:tags].join(','), opts[:format], opts[:outfile] )
end