feat(drive): add --drive and --parent flags to drive search#525
Open
LeanSheng wants to merge 1 commit intosteipete:mainfrom
Open
feat(drive): add --drive and --parent flags to drive search#525LeanSheng wants to merge 1 commit intosteipete:mainfrom
LeanSheng wants to merge 1 commit intosteipete:mainfrom
Conversation
Users had no CLI-native way to scope a Drive search to a specific
shared drive or folder. Workarounds required either raw query syntax
(which only matches direct children) or direct API calls bypassing
gog entirely, defeating the purpose of the CLI.
This adds two new flags to 'drive search':
--drive <driveId> Scopes search to a specific shared drive using
corpora=drive&driveId=X. This is the Drive API's
proper pattern for within-drive recursive search.
Mutually exclusive with --no-all-drives.
--parent <folderId> Wraps the query with "'<folderId>' in parents"
to scope results to direct children of a folder
(matching 'drive ls --parent' semantics).
Mutually exclusive with --raw-query (users with
raw queries can include the clause themselves).
Implementation:
* driveFilesListCallWithDriveSupport takes a new driveID argument;
when non-empty it sets Corpora("drive").DriveId(X), overriding
the generic Corpora("allDrives") path.
* driveFileListOptions gains a driveID field.
* DriveSearchCmd validates flag combinations up front.
Behavior change:
* No-args search behavior unchanged — existing users see no change.
* The sole caller of driveFilesListCallWithDriveSupport passes the
new driveID from options, preserving current corpora=allDrives
behavior by default.
Tests added:
* TestDriveSearchCmd_WithDrive — verifies corpora=drive+driveId wire
* TestDriveSearchCmd_WithParent — verifies query clause injection
* TestDriveSearchCmd_DriveAndParent_Combine — verifies the common
combo of scoping by shared drive + folder works together
* TestDriveSearchCmd_DriveAndNoAllDrives_Conflicts
* TestDriveSearchCmd_ParentAndRawQuery_Conflicts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
gog drive search:--drive <driveId>— scopes to a specific shared drive viacorpora=drive&driveId=X(the Drive API's proper pattern for recursive within-drive search). Mutually exclusive with--no-all-drives.--parent <folderId>— wraps the query with'<folderId>' in parents, matchingdrive ls --parentsemantics (direct children only, since the Drive API doesn't support recursive parent queries). Mutually exclusive with--raw-query.driveFilesListCallWithDriveSupportwith adriveIDarg (sole non-test caller,listDriveFiles, passes it through from the newdriveFileListOptions.driveID).DriveSearchCmd.Runvalidates flag combinations up front, before any API call.Test plan
go build ./...go vet ./...go test ./internal/cmd/... -count=1 -timeout 60s(full suite green)TestDriveSearchCmd_WithDrive,..._WithParent,..._DriveAndParent_Combine,..._DriveAndNoAllDrives_Conflicts,..._ParentAndRawQuery_Conflicts— all passgog drive search "report" --drive $(gog drive drives --format=json | jq -r '.drives[0].id')returns results from that shared drive onlygog drive search "report" --parent <folderId>returns only direct children of that foldergog drive search foo --drive X --no-all-drivesfails fast with a clear error