aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--golings/cmd/run.go20
-rw-r--r--golings/cmd/verify.go6
2 files changed, 22 insertions, 4 deletions
diff --git a/golings/cmd/run.go b/golings/cmd/run.go
index bf909a4..3fb6c5b 100644
--- a/golings/cmd/run.go
+++ b/golings/cmd/run.go
@@ -3,9 +3,11 @@ package cmd
import (
"errors"
"fmt"
+ "time"
"github.com/fatih/color"
"github.com/mauricioabreu/golings/golings/exercises"
+ "github.com/schollz/progressbar/v3"
"github.com/spf13/cobra"
)
@@ -17,7 +19,25 @@ func RunCmd(infoFile string) *cobra.Command {
SilenceUsage: true,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {
+ spinner := progressbar.NewOptions(
+ -1,
+ progressbar.OptionEnableColorCodes(true),
+ progressbar.OptionSetDescription(color.WhiteString("Running exercise: %s", args[0])),
+ progressbar.OptionOnCompletion(func() {
+ color.White("\nRunning complete!\n\n")
+ }),
+ )
+ go func() {
+ for x := 0; x < 100; x++ {
+ spinner.Add(1) // nolint
+ time.Sleep(250 * time.Millisecond)
+ }
+ }()
+
result, err := exercises.Run(args[0], infoFile)
+
+ spinner.Close()
+
if errors.Is(err, exercises.ErrExerciseNotFound) {
color.White("No exercise found for '%s'", args[0])
} else if err != nil {
diff --git a/golings/cmd/verify.go b/golings/cmd/verify.go
index 0e020e2..f713981 100644
--- a/golings/cmd/verify.go
+++ b/golings/cmd/verify.go
@@ -44,10 +44,8 @@ func VerifyCmd(infoFile string) *cobra.Command {
for _, e := range exs {
bar.Describe(fmt.Sprintf("Running %s", e.Name))
result, _ := exercises.Run(e.Name, "info.toml")
- if err := bar.Add(1); err != nil {
- color.Red(err.Error())
- os.Exit(1)
- }
+ bar.Add(1) // nolint
+
if result.Err != "" {
fmt.Print("\n\n")
color.Cyan("Failed to compile the exercise %s\n\n", e.Path)