diff options
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/hint.go | 27 | ||||
-rw-r--r-- | src/cmd/list.go | 27 | ||||
-rw-r--r-- | src/cmd/root.go | 23 | ||||
-rw-r--r-- | src/cmd/run.go | 33 |
4 files changed, 0 insertions, 110 deletions
diff --git a/src/cmd/hint.go b/src/cmd/hint.go deleted file mode 100644 index a315a91..0000000 --- a/src/cmd/hint.go +++ /dev/null @@ -1,27 +0,0 @@ -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) - }, -} diff --git a/src/cmd/list.go b/src/cmd/list.go deleted file mode 100644 index 103ea21..0000000 --- a/src/cmd/list.go +++ /dev/null @@ -1,27 +0,0 @@ -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) - }, -} diff --git a/src/cmd/root.go b/src/cmd/root.go deleted file mode 100644 index e0164a7..0000000 --- a/src/cmd/root.go +++ /dev/null @@ -1,23 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - - "github.com/spf13/cobra" -) - -var rootCmd = &cobra.Command{ - Use: "golings", - Short: "Learn go through interactive exercises", - Run: func(cmd *cobra.Command, args []string) { - - }, -} - -func Execute() { - if err := rootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) - } -} diff --git a/src/cmd/run.go b/src/cmd/run.go deleted file mode 100644 index 300478f..0000000 --- a/src/cmd/run.go +++ /dev/null @@ -1,33 +0,0 @@ -package cmd - -import ( - "os" - - "github.com/fatih/color" - "github.com/mauricioabreu/golings/src/exercises" - "github.com/spf13/cobra" -) - -func init() { - rootCmd.AddCommand(cmdRun) -} - -var cmdRun = &cobra.Command{ - Use: "run [exercise]", - Short: "Run a single exercise", - Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), - Run: func(cmd *cobra.Command, args []string) { - result, err := exercises.Run(args[0]) - if err != nil { - 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) - } - }, -} |