class Omega::CLI
Constants
- GENERAL_DOC
- SUB_COMMANDS
Attributes
omega[R]
Public Class Methods
new(_)
click to toggle source
# File lib/omega/cli.rb, line 50 def initialize(_) @cmd = ARGV.shift @cmd_opts = case @cmd when 'register-users' Optimist.options do opt :contest, 'Contest ShortName or identifier', type: :string opt :user, 'Username or email', type: :string opt :from, 'Another constest that allows to clone users from another contest', type: :string opt :user_file, 'A file containing the users list one per line and without header', type: :string end when 'user' Optimist.options do opt :user, 'Username or email', type: :string end when 'scoreboard' Optimist.options do opt :contest, 'Contest ShortName or identifier', type: :string end when 'clarifications' Optimist.options do opt :contest, 'Contest ShortName or identifier', type: :string opt :open, 'Filter to only open clars' end when 'sources' Optimist.options do opt :contest, 'Contest ShortName or identifier', type: :string opt :path, 'Path to store results', type: :string end # when 'create-contest' # Optimist.options do # opt :contest, 'Contest ShortName or identifier', type: :string # end # when 'add-problem' # Optimist.options do # opt :contest, 'Contest ShortName or identifier', type: :string # opt :problem, type: :string # end else print_help exit(0) end end
Public Instance Methods
execute()
click to toggle source
# File lib/omega/cli.rb, line 107 def execute login case @cmd when 'register-users' register_user(@cmd_opts[:contest], @cmd_opts[:user]) if @cmd_opts[:user] register_users(@cmd_opts[:contest], @cmd_opts[:user_file]) if @cmd_opts[:user_file] copy_users(@cmd_opts[:contest], @cmd_opts[:from]) if @cmd_opts[:from] when 'user' user_data(@cmd_opts[:user]) when 'scoreboard' scoreboard(@cmd_opts[:contest]) when 'clarifications' clarifications(@cmd_opts[:contest], @cmd_opts[:open]) when 'sources' download_sources(@cmd_opts[:contest], @cmd_opts[:path]) end end
login()
click to toggle source
# File lib/omega/cli.rb, line 94 def login config = { 'omega' => { 'endpoint' => ENV['OMEGAUP_URL'] || 'https://omegaup.com', 'user' => ENV['OMEGAUP_USER'], 'pass' => ENV['OMEGAUP_PASS'] } } @omega = Omega::Client.new(config['omega']) @omega.login end
print_help()
click to toggle source
# File lib/omega/cli.rb, line 46 def print_help puts GENERAL_DOC end