aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/run.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/cmd/run.go b/src/cmd/run.go
index fb62f67..300478f 100644
--- a/src/cmd/run.go
+++ b/src/cmd/run.go
@@ -1,7 +1,6 @@
package cmd
import (
- "fmt"
"os"
"github.com/fatih/color"
@@ -18,14 +17,17 @@ var cmdRun = &cobra.Command{
Short: "Run a single exercise",
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
- out, err := exercises.Run(args[0])
- fmt.Println(out)
+ result, err := exercises.Run(args[0])
if err != nil {
- color.Red("Your exercise is failing: %s", err)
+ color.Red("Compilation of %s failed! Compiler error message:\n\n%s", result.Exercise.Path, result.Err)
+ color.Yellow("If you feel stuck, ask a hint by executing `golings hint %s`", result.Exercise.Name)
os.Exit(1)
+ } else {
+ color.Green("Congratulations!\n\n")
+ color.Green("Remove the 'I AM NOT DONE' from the file to keep going\n")
+ color.Green("Here is the output of your program:\n\n")
+ color.Cyan(result.Out)
+ os.Exit(0)
}
- color.Green("Congratulations!")
- color.Green("Remove the 'I AM NOT DONE' from the file to keep going")
- os.Exit(0)
},
}