|
- require_relative 'lib/kgrader'
-
- def die(error)
- abort "fatal: [#{error.class}] #{error}"
- end
-
- def run
- yield KGrader::CLI.new Rake.application.original_dir
- rescue KGrader::KGraderError => err
- die err
- end
-
- def parse_args(num, keywords = {})
- args, options = KGrader::parse_args ARGV.drop(1), num, keywords
- args.each { |arg| task arg.to_sym {} unless arg.nil? }
- args + [options]
- rescue KGrader::KGraderError => err
- die err
- end
-
- task :default => :help do ; end
-
- task :help do
- puts %{usage:
- - rake list [<course>] [<semester>]
- - rake roster <course> <rosterfile> [<semester>]
- - rake grade <course> <assignment> [semester=<...>] [students=<...>]
- [due=<...>] [fetch=<yes/no>] [regrade=<yes/no>]
- - rake commit <course> <assignment> [semester=<...>] [students=<...>]
- - rake clean
- - rake clobber}
- end
-
- task :list do
- course, semester = parse_args 0..2
- run { |cli| cli.list course, semester }
- end
-
- task :roster do
- course, rosterfile, semester = parse_args 2..3
- run { |cli| cli.roster course, semester, rosterfile }
- end
-
- task :grade do
- course, assignment, options = parse_args 2..2,
- { :semester => :string, :students => :array, :due => :time,
- :fetch => :bool, :regrade => :bool }
- semester, students = options[:semester], options[:students]
- run { |cli| cli.grade course, semester, assignment, students, options }
- end
-
- task :commit do
- course, assignment, options = parse_args 2..2,
- { :semester => :string, :students => :array }
- semester, students = options[:semester], options[:students]
- run { |cli| cli.commit course, semester, assignment, students }
- end
-
- task :clean do
- run { |cli| cli.clean }
- end
-
- task :clobber do
- run { |cli| cli.clobber }
- end
|