Skip to content

Commit

Permalink
chore: adding a spinner when fecthing remote data
Browse files Browse the repository at this point in the history
Signed-off-by: Yves Brissaud <[email protected]>
  • Loading branch information
eunomie committed Oct 9, 2024
1 parent abac60e commit 20f5dc5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/commands/decorate/decorate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewCmd(dockerCli command.Cli) *cobra.Command {
image := args[0]

err = spinner.New().
Type(spinner.MiniDot).
Type(spinner.Globe).
Title(" Decorating and pushing...").
Action(func() {
err = runkit.Decorate(cmd.Context(), image, tag, config, readme)
Expand Down
20 changes: 18 additions & 2 deletions internal/commands/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"context"
"fmt"
"io"
"os"
"strings"

"github.com/charmbracelet/huh/spinner"
"github.com/gertd/go-pluralize"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -37,8 +39,22 @@ func NewCmd(dockerCli command.Cli, isPlugin bool) *cobra.Command {
return cmd.Help()
}

src := args[0]
rk, err := runkit.Get(cmd.Context(), src)
var (
src = args[0]
err error
rk *runkit.RunKit
)

err = spinner.New().
Type(spinner.Globe).
Title(" Fetching runx details...").
Action(func() {
rk, err = runkit.Get(cmd.Context(), src)
if err != nil {
_, _ = fmt.Fprintln(dockerCli.Err(), err)
os.Exit(1)
}
}).Run()
if err != nil {
return err
}
Expand Down

0 comments on commit 20f5dc5

Please sign in to comment.