class Simp::Metadata::Commands::Script
Public Instance Methods
run(argv, engine = nil)
click to toggle source
# File lib/simp/metadata/commands/script.rb, line 8 def run(argv, engine = nil) options = defaults(argv) do |opts,options| opts.banner = 'Usage: simp-metadata script [options] <filename>' end $commandqueue = Queue.new engine, root = get_engine(engine, options) if argv[0].nil? Simp::Metadata.critical('filename must be specified') exit 3 end data = File.read(argv[0]) lines = data.split("\n") lines.each do |line| temp_argv = line.split(' ') next if temp_argv.empty? next if temp_argv[0] =~ /^#/ $commandqueue.push(line) command = Module.const_get("Simp::Metadata::Commands::#{temp_argv[0].tr('-', '_').capitalize}").new temp_argv.shift command.run(temp_argv, engine) end end