[Feature] Add --include flag to delete devices option #48
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.
Add
--includeflag todelete devicescommandSummary
This PR adds an
--includeflag to thetscli delete devicescommand, allowing users to filter devices by name patterns for inclusion (complementing the existing--excludeflag).Changes
--includeflag that filters devices by partial name match (can be specified multiple times)--includeand--excludemutually exclusive to avoid confusing behaviornewClientvariable for dependency injection (consistent withget/device)Usage
Delete only devices matching specific patterns
tscli delete devices --last-seen 24h --include dev --include test --confirm
Using exclude (existing behavior)
tscli delete devices --last-seen 24h --exclude prod --confirm
Cannot use both (returns error)
tscli delete devices --include dev --exclude prod # Error: mutually exclusive### Why mutually exclusive?
Using both
--includeand--excludetogether can lead to confusing semantics (include first then exclude? or vice versa?). Keeping them mutually exclusive makes the behavior predictable and easy to understand.Testing
go test ./cmd/tscli/delete/devices/... -vAll tests pass, including:
isIncludedandisExcludedhelper functionsImportant
Add
--includeflag totscli delete devicesfor device name filtering, making it mutually exclusive with--exclude, with tests added.--includeflag totscli delete devicesfor filtering devices by name patterns.--includeand--excludeflags mutually exclusive incli.go.isIncluded()function incli.goto check device name inclusion.deleteDisconnectedDevices()incli.goto handleincludelogic.TestDeleteDevicesFlagValidationincli_test.gofor flag validation.TestIsIncludedandTestIsExcludedincli_test.gofor helper functions.This description was created by
for 6fb5239. You can customize this summary. It will automatically update as commits are pushed.