aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/list.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cmd/list.go b/src/cmd/list.go
new file mode 100644
index 0000000..103ea21
--- /dev/null
+++ b/src/cmd/list.go
@@ -0,0 +1,27 @@
+package cmd
+
+import (
+ "os"
+
+ "github.com/fatih/color"
+ "github.com/mauricioabreu/golings/src/exercises"
+ "github.com/mauricioabreu/golings/src/printer"
+ "github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(cmdList)
+}
+
+var cmdList = &cobra.Command{
+ Use: "list",
+ Short: "List all exercises",
+ Run: func(cmd *cobra.Command, args []string) {
+ exs, err := exercises.List()
+ if err != nil {
+ color.Red(err.Error())
+ os.Exit(1)
+ }
+ printer.PrintList(os.Stdout, exs)
+ },
+}