class TestML::Command
Constants
- VERSION
Public Class Methods
new(args)
click to toggle source
# File lib/testml/command.rb, line 19 def initialize(args) @args = args @file = nil @testml = nil @bridge = [] @argv = [] get_options(args) end
Public Instance Methods
error(msg)
click to toggle source
# File lib/testml/command.rb, line 66 def error(msg) fail "Error: #{msg}\n\n#{usage}\n" end
get_options(args)
click to toggle source
# File lib/testml/command.rb, line 28 def get_options(args) while arg = args.shift if arg =~ /^(?:-b|--bridge(?:=(.*))?)$/ b = $1 || args.shift or error '-b|--bridge requires a value' @bridge.concat(b.split(',')) elsif File.exists?(arg) @file = arg break elsif arg =~ /^--?$/ break elsif arg !~ /^-/ error "Input file '#{arg}' does not exist" else error "Unrecognized argument '#{arg}'" end end @testml = @file ? File.read(@file) : STDIN.read @argv = TestML::List.new(args.map {|a| TestML::String.new(a)}) end
run()
click to toggle source
# File lib/testml/command.rb, line 49 def run @runtime = TestML::Runtime::Lang.new( testml: @testml, bridge: @bridge, compiler: TestML::Compiler::Pegex, library: [ TestML::Library::Standard, TestML::Library::Debug, ], ) @runtime.compile_testml @runtime.initialize_runtime #XXX @runtime @runtime.global.setvar('ARGV', @argv) @runtime.run_function(@runtime.function, []) end
usage()
click to toggle source
# File lib/testml/command.rb, line 9 def usage <<'...' Usage: testml [testml-options] (<testml-file> | -) [runtime arguments] TestML Options: -b, --bridge= <bridge-class[,bridge-class-list]> ... end