lib/coursemology/evaluator/cli.rb in coursemology-evaluator-0.1.8 vs lib/coursemology/evaluator/cli.rb in coursemology-evaluator-0.1.9

- old
+ new

@@ -1,11 +1,11 @@ # frozen_string_literal: true require 'optparse' class Coursemology::Evaluator::CLI Options = Struct.new(:host, :api_token, :api_user_email, - :one_shot, :poll_interval, :image_lifetime) + :one_shot, :poll_interval, :image_lifetime, :sleep_time) def self.start(argv) new.start(argv) end @@ -22,10 +22,13 @@ Coursemology::Evaluator.config.image_lifetime = ::ISO8601::Duration.new("P#{options.image_lifetime}".upcase).to_seconds Coursemology::Evaluator::Client.initialize(options.host, options.api_user_email, options.api_token) + + # Sleep before start + sleep(::ISO8601::Duration.new("PT#{options.sleep_time}".upcase).to_seconds) Coursemology::Evaluator::Client.new(options.one_shot).run end private @@ -38,10 +41,11 @@ # default options for optional parameters options.poll_interval = '10S' options.image_lifetime = '1D' options.one_shot = false + options.sleep_time = '0S' option_parser = OptionParser.new do |parser| parser.banner = "Usage: #{parser.program_name} [options]" parser.on('-hHOST', '--host=HOST', 'Coursemology host to connect to') do |host| options.host = host @@ -63,9 +67,13 @@ options.image_lifetime = lifetime end parser.on('-o', '--one-shot') do options.one_shot = true + end + + parser.on('-sSLEEP', '--sleep=SLEEPTIME') do |sleeptime| + options.sleep_time = sleeptime end end option_parser.parse!(argv) options