Skip to content

feat: add filtering options to list-sources#18

Merged
patrick204nqh merged 1 commit into
mainfrom
feat/list-sources-filtering
Feb 11, 2026
Merged

feat: add filtering options to list-sources#18
patrick204nqh merged 1 commit into
mainfrom
feat/list-sources-filtering

Conversation

@patrick204nqh
Copy link
Copy Markdown
Owner

Summary

  • Add --collector flag to filter by collector name before fetching sources (avoids unnecessary API calls)
  • Add -n/--name flag to filter sources by name
  • Add --category flag to filter sources by category
  • Add -l/--limit flag to cap total sources returned
  • All filters are case-insensitive substring matches

Details

The key optimization is pre-filtering collectors by name before the parallel source fetch. In environments with 200+ collectors, specifying --collector "my-service" might narrow down to 3-5 collectors, eliminating ~98% of API calls and avoiding rate-limit errors.

Source-level filters (--name, --category) are applied as post-filters after fetching. Collectors with no matching sources after filtering are excluded from output. --limit is applied last, capping total sources across all collectors.

Files changed:

  • lib/sumologic/cli.rb — Thor option declarations and updated help text
  • lib/sumologic/cli/commands/list_sources_command.rb — Pass filter options to client
  • lib/sumologic/metadata/source.rb — Collector pre-filter, source post-filter, limit logic
  • lib/sumologic/client.rb — Updated list_all_sources facade signature
  • spec/sumologic/metadata/source_spec.rb — New: 11 tests for filtering/limiting
  • spec/sumologic/cli/commands/commands_spec.rb — Updated command tests

Test plan

  • 11 new metadata tests: collector filter, source name/category filter, combined filters, limit, filter+limit, empty result exclusion
  • Updated command spec verifies filter option passthrough
  • Full suite: 169/169 passing

Closes #12

Add --collector, --name, --category, and --limit flags to list-sources.

When --collector is specified, the collector list is filtered by name
before fetching sources, avoiding unnecessary API calls to collectors
that don't match. Source-level filters (--name, --category) are applied
as post-filters, and --limit caps total sources across all collectors.

Closes #12.
@patrick204nqh patrick204nqh force-pushed the feat/list-sources-filtering branch from b7939e6 to ee3ecde Compare February 11, 2026 08:42
@patrick204nqh patrick204nqh merged commit d73dbec into main Feb 11, 2026
2 checks passed
@patrick204nqh patrick204nqh deleted the feat/list-sources-filtering branch February 11, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add filtering options to list-sources

1 participant