cmd/gonix: replace alecthomas/kong with stdlib flag#8
Open
aldoborrero wants to merge 1 commit intomainfrom
Open
cmd/gonix: replace alecthomas/kong with stdlib flag#8aldoborrero wants to merge 1 commit intomainfrom
aldoborrero wants to merge 1 commit intomainfrom
Conversation
56924af to
313fc2b
Compare
This was referenced Apr 2, 2026
313fc2b to
30f69f2
Compare
The gonix CLI is small (4 subcommands, 2 flags, 7 positionals) — well within stdlib flag's reach. Dispatch on os.Args[1] in main, then each subpackage's Main() builds a FlagSet per subcommand and reads positionals from fs.Args(). The custom drv-store-uri kong mapper becomes a plain NewFromURI call after flag parsing. Per-subcommand files (cat.go, dump.go, ls.go, show.go) keep their Cmd structs and Run() methods; only the kong struct tags are stripped. Help text and arg-count validation are explicit. Drops alecthomas/kong (and transitively alecthomas/repr, pkg/errors) from go.mod.
30f69f2 to
1059ea7
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.
The
gonixCLI is small — 4 subcommands, 2 flags, 7 positional args. Well within stdlibflag's reach.Approach
main.godispatches onos.Args[1]tonar.Main()/drv.Main()Main()builds aflag.FlagSetper subcommand and reads positionals fromfs.Args()drv-store-urikong mapper becomes a plainderivationStore.NewFromURIcall after parsingPer-subcommand files (
cat.go,dump.go,ls.go,show.go) keep theirCmdstructs andRun()methods unchanged — only the kong struct tags are stripped. Help text and arg-count validation become explicit.Behavior preserved
Error paths (
unknown command, missing positionals,--help) all produce sensible output.Dependency reduction
Drops
alecthomas/kongand transitivelyalecthomas/repr+pkg/errorsfrom go.sum. First of a small series trimming the dependency surface.