aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2021-09-06 21:06:02 -0500
committerFurkan Sahin <furkan-dev@proton.me>2021-09-06 21:06:02 -0500
commite4c3de10306fd7eee993f8b5e954337575709e89 (patch)
treeba2277b505db5f1aacd011d4dd4614370ac38110 /cmd
parentc0288be34b6db18accf7e585c679764cf36f80c3 (diff)
Add --extra flag to print addtional configuration info
Diffstat (limited to 'cmd')
-rw-r--r--cmd/planr/sub/cli.go28
-rw-r--r--cmd/planr/sub/evaluate.go13
2 files changed, 31 insertions, 10 deletions
diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go
index 39f56b4..c7b1ee4 100644
--- a/cmd/planr/sub/cli.go
+++ b/cmd/planr/sub/cli.go
@@ -17,8 +17,8 @@ var (
func tcTitle(tr planr.TestResult) string {
title := tr.Tc.Cname
- if tr.Tc.Config.Title != nil {
- title = *tr.Tc.Config.Title
+ if tr.Tc.Config.Title != "" {
+ title = tr.Tc.Config.Title
}
return title
@@ -70,20 +70,34 @@ func tcStatusLine(tr planr.TestResult) {
col_title.Println(title);
}
-func tcPprint(tr planr.TestResult) {
+type PrintOpts int
+
+const (
+ PRINT_CONCISE PrintOpts = 1 << iota
+ PRINT_DESCRIPTION
+ PRINT_POINTS
+)
+
+func (opt PrintOpts) HasFlag(flag PrintOpts) bool {
+ return (opt & flag) == flag
+}
+
+func tcPprint(tr planr.TestResult, opt PrintOpts) {
tcStatusLine(tr)
tc := tr.Tc
pprintLabeled("id", tc.Cname)
- if tc.Config.Points != nil {
+ if tc.Config.Points != nil && opt.HasFlag(PRINT_POINTS) {
points := fmt.Sprintf("%.1f", *tc.Config.Points)
- pprintLabeled("points", points)
+ pprintLabeled("points1", points)
}
- if tc.Config.Description != nil {
- pprintLabeled("description", *tc.Config.Description)
+ if tc.Config.Description != "" && opt.HasFlag(PRINT_DESCRIPTION) {
+ tabbed := strings.ReplaceAll(tc.Config.Description, "\n", "\n ")
+
+ pprintLabeled("description", tabbed)
}
if tr.Status == planr.COMPILATION_FAILURE {
diff --git a/cmd/planr/sub/evaluate.go b/cmd/planr/sub/evaluate.go
index 79d2b23..2763599 100644
--- a/cmd/planr/sub/evaluate.go
+++ b/cmd/planr/sub/evaluate.go
@@ -14,9 +14,15 @@ type gradingResults struct {
Score planr.Scoring
}
-func prettyPrint(results gradingResults, summarize bool) {
+func prettyPrint(results gradingResults, verbose, summarize bool) {
for _, tr := range results.TestResults {
- tcPprint(tr)
+ opts := PRINT_CONCISE
+
+ if verbose {
+ opts = opts | PRINT_DESCRIPTION | PRINT_POINTS
+ }
+
+ tcPprint(tr, opts)
}
if summarize {
@@ -38,6 +44,7 @@ func Evaluate(runner planr.Runner, params []string, cfg *planr.Config) {
f := flag.NewFlagSet("evaluate", flag.ExitOnError)
jsonOutput := f.Bool("json", false, "print json output")
+ extra := f.Bool("extra", false, "print extra grading information")
dieIncompatibleVersion(cfg)
@@ -76,6 +83,6 @@ func Evaluate(runner planr.Runner, params []string, cfg *planr.Config) {
if *jsonOutput {
jsonPrint(results)
} else {
- prettyPrint(results, summarizeScore)
+ prettyPrint(results, *extra, summarizeScore)
}
}