Repository navigation
refactor: move the root command to internal/cmd - #476
Merged
Merged
Conversation
thde
force-pushed
the
refactor/root-command
branch
4 times, most recently
from
October 15, 2026 14:00
1223f5a to
8b53d7c
Compare
Suggested command lines no longer depend on os.Args[0], so hints read nctl like the usage output does, regardless of how the binary was invoked. GetCmd no longer lowercases its arguments in place, and the unused SetOrg is gone.
The client is now a singleton provider, so kong only builds it for commands whose Run method takes an *api.Client. This replaces the list of command names which had to be kept in sync with the command tree. A failing client setup is reported as a cli.Error like other errors.
main only wires the process to cmd.Run: signals, arguments, standard streams, the version and the exit code. Run returns the exit code instead of exiting, turning the exits kong performs into a return, so the whole CLI can be tested in-process. The missing-command hint no longer exits by itself, a second signal still terminates nctl with signal.NotifyContext, and only the root command may import the verbs.
The tests guard the layering below the root command, so they live next to it as deps_test.go, after go/build/deps_test.go. They find the module root through go.mod instead of relying on the working directory.
thde
force-pushed
the
refactor/root-command
branch
from
October 15, 2026 14:07
8b53d7c to
8735c40
Compare
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.
Suggested command lines no longer depend on os.Args[0],
so hints read nctl like the usage output does,
regardless of how the binary was invoked.
GetCmd no longer lowercases its arguments in place,
and the unused SetOrg is gone.
The client is now a singleton provider,
so kong only builds it for commands whose Run method takes an *api.Client.
This replaces the list of command names
which had to be kept in sync with the command tree.
A failing client setup is reported as a cli.Error like other errors.
main only wires the process to cmd.Run:
signals, arguments, standard streams, the version and the exit code.
Run returns the exit code instead of exiting,
turning the exits kong performs into a return,
so the whole CLI can be tested in-process.
The missing-command hint no longer exits by itself,
a second signal still terminates nctl with signal.NotifyContext,
and only the root command may import the verbs.
The tests guard the layering below the root command,
so they live next to it as deps_test.go, after go/build/deps_test.go.
They find the module root through go.mod
instead of relying on the working directory.