feat: wire the cdd CLI (cdd, init, scan, version) - #41
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Builds the cobra command tree, an exported Run(args, stdout, stderr) so tests can drive it in-process, and exit-code classification (0/130/1/2) per the command surface decision. version/commit/date stay the ldflags var names the scaffold and .goreleaser.yaml expect. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pick loads config, opens History at its default path, and resolves the query to a Project via jump.Resolve and picker.Run, printing only the absolute path to stdout. The bare root command shares this RunE. A cancelled Picker is reported by Run as a silent exit 130. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Prints "Seeded N Visits across M Projects" from scan.Run's Summary. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Requires exactly one shell argument in fish, bash, zsh (usage error otherwise) and renders the Wrapper via shell.Script, passing a pass-through list built from the cobra command tree so help and completion forward without hand maintenance. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Drives cli.Run in-process with cobra's SetArgs and captured stdout/stderr: version formatting and its --version/-V aliases, unknown command/flag exit 2, init's usage errors and tree-derived passthrough list, pick/scan arg-count usage errors, and help. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Closed
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.
What
Wires
internal/clitogithub.com/spf13/cobra: the rootcddcommand(bare behaves as
pick),pick [query],init <shell>,scan,version, plus cobra's ownhelpandcompletioncommands. Flags--help/-hand--version/-V(the latter prints the same output ascdd version).pickloads config, opens History at its default path, and resolves thequery via
jump.Resolve+picker.Run, printing only the chosenProject's absolute path (plus newline) to stdout. A cancelled Picker
exits 130 silently; any other error exits 1 with a stderr message. When
stdout is a terminal, a stderr hint suggests installing the Wrapper via
cdd init <shell> | source.initrequires exactly one shell argument (fish,bash,zsh),otherwise exits 2 listing them. The Wrapper's pass-through list is
derived from the cobra command tree (every command name except
pick),so
helpandcompletionforward without hand maintenance.scanprintsSeeded N Visits across M Projectsand exits 0.versionformatsversion/commit/date(same var names the scaffoldand
.goreleaser.yamlalready reference via ldflags), falling back tocdd dev (dev)for local builds.shell) exit 2; runtime errors exit 1 with a stderr message; a cancelled
Picker exits 130 with no message.
internal/cli.Run(args, stdout, stderr) intis exported alongsideExecute()so tests drive the command tree in-process with cobra'sSetArgsand captured buffers, rather than exec'ing a built binary.Testing
go build ./... && go vet ./... && go test ./...all pass. Table-driventests in
internal/cli/cli_test.gocover version formatting and itsflag aliases, unknown command/flag exit codes,
init's usage errors andtree-derived passthrough list,
pick/scanarg-count usage errors, andhelp output.
Closes #21
🤖 Generated with Claude Code