Sha256: 6988a9efa280aa9bc81e727170c7fc3a41e8d533cd0964ef158424891374c34c
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# tap run {options} -- {task options} task INPUTS... # # examples: # tap run --help Prints this help # tap run -- task --help Prints help for task # env = Tap::Env.instance app = Tap::App.instance # # handle options # dump = false OptionParser.new do |opts| cmdline = Tap::Support::CommandLine opts.separator "" opts.separator "configurations:" Tap::App.configurations.each do |receiver, key, config| next if receiver == Tap::Root opts.on(*cmdline.configv(config)) do |value| app.send(config.writer, value) end end opts.separator "" opts.separator "options:" opts.on("-h", "--help", "Show this message") do opts.banner = cmdline.usage(__FILE__) Tap::App.lazydoc.resolve puts opts exit end opts.on('-T', '--manifest', 'Print a list of available tasks') do |v| puts env.summarize(:tasks) {|const| const.document[const.name]['manifest'] } exit end end.parse!(ARGV) # # handle options for each specified task # rounds = env.parse(ARGV) ARGV.clear if rounds.empty? puts "no task specified" exit end # # set signals # # info signal -- Note: some systems do # not support the INFO signal # (windows, fedora, at least) signals = Signal.list.keys if signals.include?("INFO") Signal.trap("INFO") do puts app.info end end # interuption signal if signals.include?("INT") Signal.trap("INT") do puts " interrupted!" # prompt for decision while true print "stop, terminate, exit, or resume? (s/t/e/r):" case gets.strip when /s(top)?/i app.stop break when /t(erminate)?/i app.terminate break when /e(xit)?/i exit when /r(esume)?/i break else puts "unexpected response..." end end end end # # enque tasks and run! # rounds.each_with_index do |queue, i| app.queue.concat(queue) app.run end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bahuvrihi-tap-0.10.2 | cmd/run.rb |