Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Community Contribution License
All community contributions in this pull request are licensed to the project maintainers
under the terms of the Apache 2 license.
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.
Description
This PR adds a
--count-onlyflag tomc lsto print only the total number of entries found, without printing each object/dir line. This is useful for scripting and quick “how many things are here?” checks.Additionally, it extracts the storage-class filter condition into a small helper (
storageClassAllowed) and adds a unit test covering that logic.Behavior with
--count-only:Motivation and Context
When working with large buckets,
mc lsoutput can be expensive and noisy if you only need a count (e.g., CI scripts, smoke checks, automation).--count-onlyenables efficient counting without formatting or printing each entry.The
storageClassAllowedhelper keeps the listing logic clearer and makes the storage-class filter behavior directly unit-testable.How to test this PR?
Unit tests
Run the new unit test:
go test ./cmd -run TestStorageClassAllowed -vRun full suite:
go test ./...Manual / functional checks
go build -o mc-dev .Expected:
--count-onlyprints a single number, and no object lines.Types of changes
Checklist:
commit-idorPR #here)