Skip to content

Commit

Permalink
Show spinner while pushing package (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
jradtilbrook authored Sep 10, 2024
1 parent c316549 commit d57bc94
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/pkg/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
func NewCmdPackage(f *factory.Factory) *cobra.Command {
cmd := cobra.Command{
Use: "package <command>",
Aliases: []string{"pkg"},
Short: "Manage packages",
Long: "Work with Buildkite Packages",
PersistentPreRunE: validation.CheckValidConfiguration(f.Config),
Expand Down
18 changes: 14 additions & 4 deletions pkg/cmd/pkg/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 [email protected]")
}

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)
}
Expand Down

0 comments on commit d57bc94

Please sign in to comment.