aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurĂ­cio Antunes <mauricio.abreua@gmail.com>2022-11-17 20:01:10 -0300
committerMaurĂ­cio Antunes <mauricio.abreua@gmail.com>2022-11-17 20:01:10 -0300
commit542ac41c9b40730f301c009cdbc9225d42486dca (patch)
tree868ab4e0eff0785015a2cbb9baf0d6ae2efb04c7
parent698fde4e352fb1b93abc64b38f2118805c83d332 (diff)
feat: exit with a different message for exercises not found
-rw-r--r--golings/cmd/run.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/golings/cmd/run.go b/golings/cmd/run.go
index 0278795..ff3fa70 100644
--- a/golings/cmd/run.go
+++ b/golings/cmd/run.go
@@ -1,6 +1,7 @@
package cmd
import (
+ "errors"
"os"
"github.com/fatih/color"
@@ -14,7 +15,10 @@ var cmdRun = &cobra.Command{
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
result, err := exercises.Run(args[0], "info.toml")
- if err != nil {
+ if errors.Is(err, exercises.ErrExerciseNotFound) {
+ color.White("No exercise found for '%s'", args[0])
+ os.Exit(1)
+ } else if err != nil {
color.Cyan("Failed to compile the exercise %s\n\n", result.Exercise.Path)
color.White("Check the output below: \n\n")
color.Red(result.Err)