From 4eaeda580b6f33292f3dddc0f767e4fdf803acf5 Mon Sep 17 00:00:00 2001 From: Heath Stewart Date: Fri, 11 Oct 2024 13:20:43 -0700 Subject: [PATCH] Show progress when filtering Filtering can take a while, so show progress. This also uncovered a bug that I wasn't checking if a filter was actually specified, resulting in a non-nil `opts.Filter`. --- pkg/cmd/gist/list/list.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/gist/list/list.go b/pkg/cmd/gist/list/list.go index 40e422c73..ae138d6a2 100644 --- a/pkg/cmd/gist/list/list.go +++ b/pkg/cmd/gist/list/list.go @@ -71,12 +71,12 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman if opts.IncludeContent { return cmdutil.FlagErrorf("cannot use --include-content without --filter") } - } - - if filter, err := regexp.CompilePOSIX(flagFilter); err != nil { - return err } else { - opts.Filter = filter + if filter, err := regexp.CompilePOSIX(flagFilter); err != nil { + return err + } else { + opts.Filter = filter + } } opts.Visibility = "all" @@ -115,7 +115,13 @@ func listRun(opts *ListOptions) error { host, _ := cfg.Authentication().DefaultHost() + // Filtering can take a while so start the progress indicator. StopProgressIndicator will no-op if not running. + if opts.Filter != nil { + opts.IO.StartProgressIndicator() + } gists, err := shared.ListGists(client, host, opts.Limit, opts.Filter, opts.IncludeContent, opts.Visibility) + opts.IO.StopProgressIndicator() + if err != nil { return err }