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`.
This commit is contained in:
Heath Stewart 2024-10-11 13:20:43 -07:00
parent 1615f2c1e1
commit 4eaeda580b
No known key found for this signature in database

View file

@ -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
}