require_relative 'lib/kgrader' def cli KGrader::CLI.new Rake.application.original_dir end def parse_args(num, keywords = {}) args, options = KGrader::parse_args ARGV.drop(1), num, keywords args.each { |arg| task arg.to_sym {} } args + [options] end task :default => :help do ; end task :help do puts %{usage: - rake list - rake roster - rake grade [semester=<...>] [students=<...>] [due=<...>] [fetch=] [regrade=] - rake commit [semester=<...>] [students=<...>] - rake clean - rake clobber} end task :list do cli.list end task :roster do course, semester, rosterfile = parse_args 3 cli.roster course, semester, rosterfile end task :grade do course, assignment, options = parse_args 2, { :semester => :string, :students => :array, :due => :datetime, :fetch => :bool, :regrade => :bool } cli.grade course, options[:semester], assignment, options end task :commit do course, assignment, options = parse_args 2, { :semester => :string, :students => :array } cli.commit course, options[:semester], assignment, options end task :clean do cli.clean end task :clobber do cli.clobber end