|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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>]
- [superscore=<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, :superscore => :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
|