Class: Omega::CLI
- Inherits:
-
Object
- Object
- Omega::CLI
- Includes:
- Contest
- Defined in:
- lib/omega/cli.rb,
lib/omega/cli/contest.rb
Defined Under Namespace
Modules: Contest
Constant Summary collapse
- SUB_COMMANDS =
%w[ register-users user scoreboard create-contest add-problem help ].freeze
Instance Attribute Summary collapse
-
#omega ⇒ Object
readonly
Returns the value of attribute omega.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(_) ⇒ CLI
constructor
A new instance of CLI.
- #login ⇒ Object
- #print_help ⇒ Object
Methods included from Contest
#clarifications, #register_user, #register_users, #scoreboard, #user_data
Constructor Details
#initialize(_) ⇒ CLI
Returns a new instance of CLI.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/omega/cli.rb', line 45 def initialize(_) @cmd = ARGV.shift @cmd_opts = case @cmd when 'register-users' Optimist. do opt :contest, 'Contest ShortName or identifier', type: :string opt :user, 'Username or email', type: :string opt :user_file, 'A file containing the users list one per line and without header', type: :string end when 'user' Optimist. do opt :user, 'Username or email', type: :string end when 'scoreboard' Optimist. do opt :contest, 'Contest ShortName or identifier', type: :string end when 'clarifications' Optimist. do opt :contest, 'Contest ShortName or identifier', type: :string opt :open, 'Filter to only open clars' 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 |
Instance Attribute Details
#omega ⇒ Object (readonly)
Returns the value of attribute omega.
9 10 11 |
# File 'lib/omega/cli.rb', line 9 def omega @omega end |
Instance Method Details
#execute ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/omega/cli.rb', line 96 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] when 'user' user_data(@cmd_opts[:user]) when 'scoreboard' scoreboard(@cmd_opts[:contest]) when 'clarifications' clarifications(@cmd_opts[:contest], @cmd_opts[:open]) end end |
#login ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/omega/cli.rb', line 83 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 ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/omega/cli.rb', line 21 def print_help puts %( OmegaUp CLI. Developed by OMIJal https://github.com/omijal/omegaup-cli. Tool for interacting with omegaup from CLI and available throug ruby gems. Commands: - register-users Add a user or a bunch of users to the a contest. - user Generates a dump of the user data in yml format. - scoreboard Gets contest scoreboard with users and score. - clarifications Gets contest clarifications. Parametes: --contest Contest name --user Username or email --user-file A file path containing a list of user one per line without header --open Filter to only open clarifications Setup: You need to add two env variables with your omegaup credentials. OMEGAUP_URL *Optional* This is intended for development purpose, it will target to https://omegau.com by default. OMEGAUP_USER *Required* Your OmegaUp Username or Email OMEGAUP_PASS *Required* Your OmegaUp Password ) end |