aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd
diff options
context:
space:
mode:
authorMaurĂ­cio Antunes <mauricio.abreua@gmail.com>2022-10-29 23:44:11 -0300
committerMaurĂ­cio Antunes <mauricio.abreua@gmail.com>2022-10-29 23:44:11 -0300
commit367fbaef2b082d0b76cdf0a7afa015f55f5d77c5 (patch)
tree92505f71dbb388b0ed81ba34ae2ec179621c9911 /src/cmd
parent77736509fbd2c4e75b08cdc6705d0130f7a5e1bf (diff)
feat: add hint command
Diffstat (limited to 'src/cmd')
-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)
+ },
+}