Documentation ¶
Index ¶
Constants ¶
View Source
const PROBLEM_CONFIG = "problem-config.json"
Variables ¶
View Source
var JudgeCmd = &cobra.Command{ Use: "judge", Short: "Builds, runs, and judges an input program", Long: longUsage(), Run: func(cmd *cobra.Command, args []string) { solnSrc, judgeOutput, err := validateArgs(args) if err != nil { fmt.Printf("Error validating args: %v\n", err) return } solnDir := MustStr(filepath.Abs(filepath.Dir(solnSrc))) judgeOutputFile := MustStr(filepath.Abs(judgeOutput)) possibleConfigFiles := []string{ filepath.Join(solnDir, PROBLEM_CONFIG), filepath.Join(solnDir, "../", PROBLEM_CONFIG), filepath.Join(solnDir, "../../", PROBLEM_CONFIG), filepath.Join(solnDir, "../../../", PROBLEM_CONFIG), } probCfg := "" for _, probCfg = range possibleConfigFiles { if _, err := os.Stat(probCfg); err == nil { break } } data, err := ioutil.ReadFile(probCfg) theOutput, err := RunFunc(data, opts, solnSrc, judgeOutput) fmt.Printf("err: %v", err) if err != nil { panic(err) } fmt.Printf("%s\n", MustBytes(json.MarshalIndent(theOutput, "", " "))) fmt.Printf("Writing output to %s\n", judgeOutputFile) err = ioutil.WriteFile(judgeOutputFile, MustBytes(json.Marshal(theOutput)), 0755) if err != nil { panic(err) } }, }
judgeCmd represents the judge command
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.