From d57bc944596ee7d7077056064752d4028d22dcf1 Mon Sep 17 00:00:00 2001 From: Jarryd Tilbrook Date: Tue, 10 Sep 2024 13:12:56 +0800 Subject: [PATCH] Show spinner while pushing package (#350) --- pkg/cmd/pkg/package.go | 1 + pkg/cmd/pkg/push.go | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/pkg/package.go b/pkg/cmd/pkg/package.go index 0689208c..77f03e64 100644 --- a/pkg/cmd/pkg/package.go +++ b/pkg/cmd/pkg/package.go @@ -9,6 +9,7 @@ import ( func NewCmdPackage(f *factory.Factory) *cobra.Command { cmd := cobra.Command{ Use: "package ", + Aliases: []string{"pkg"}, Short: "Manage packages", Long: "Work with Buildkite Packages", PersistentPreRunE: validation.CheckValidConfiguration(f.Config), diff --git a/pkg/cmd/pkg/push.go b/pkg/cmd/pkg/push.go index e748544a..81e08d7f 100644 --- a/pkg/cmd/pkg/push.go +++ b/pkg/cmd/pkg/push.go @@ -9,6 +9,7 @@ import ( "github.com/MakeNowJust/heredoc" "github.com/buildkite/cli/v3/pkg/cmd/factory" "github.com/buildkite/go-buildkite/v3/buildkite" + "github.com/charmbracelet/huh/spinner" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -63,10 +64,19 @@ func NewCmdPackagePush(f *factory.Factory) *cobra.Command { panic("Neither file path nor stdin file name are available, there has been an error in the config validation. Report this to support@buildkite.com") } - pkg, _, err := f.RestAPIClient.PackagesService.Create(f.Config.OrganizationSlug(), cfg.RegistrySlug, buildkite.CreatePackageInput{ - Filename: packageName, - Package: from, - }) + var pkg buildkite.Package + spinErr := spinner.New(). + Title("Pushing package"). + Action(func() { + pkg, _, err = f.RestAPIClient.PackagesService.Create(f.Config.OrganizationSlug(), cfg.RegistrySlug, buildkite.CreatePackageInput{ + Filename: packageName, + Package: from, + }) + }). + Run() + if spinErr != nil { + return spinErr + } if err != nil { return fmt.Errorf("%w: request to create package failed: %w", ErrAPIError, err) }