blob: aeec65d217b5c7cccd2548d0f1e7f5acaf041420 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package cmd
import (
"fmt"
"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) {
out, err := exercises.Run(args[0])
fmt.Println(out)
if err != nil {
color.Red("Your exercise is failing")
os.Exit(1)
}
color.Green("Congratulations!")
color.Green("Remove the 'I AM NOT DONE' from the file to keep going")
os.Exit(0)
},
}
|