aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cmd/hint.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cmd/hint.go b/src/cmd/hint.go
new file mode 100644
index 0000000..a315a91
--- /dev/null
+++ b/src/cmd/hint.go
@@ -0,0 +1,27 @@
+package cmd
+
+import (
+ "os"
+
+ "github.com/fatih/color"
+ "github.com/mauricioabreu/golings/src/exercises"
+ "github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(cmdHint)
+}
+
+var cmdHint = &cobra.Command{
+ Use: "hint",
+ Short: "Get a hint for an exercise",
+ Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
+ Run: func(cmd *cobra.Command, args []string) {
+ exercise, err := exercises.Find(args[0])
+ if err != nil {
+ color.Red(err.Error())
+ os.Exit(1)
+ }
+ color.Yellow(exercise.Hint)
+ },
+}