Repository navigation
refactor(spored): convert hand-rolled CLI to cobra (#40) - #43
Merged
Merged
Conversation
spored parsed args with a hand-rolled 'switch os.Args[1]' and manual os.Args[2:] slicing, sharing no flag infrastructure with spawn/truffle/ lagotto. Convert to a cobra command tree so it follows the same conventions, with structured help and consistent flag parsing. Every external contract is preserved exactly (spawn shells out to these and the user-data bootstrap depends on them): - bare 'spored' → lifecycle daemon (extracted to runDaemon()) - 'spored status --check-complete' → exit codes 0/1/2/3 (unchanged) - 'spored config get|set|list', 'spored reload' - 'spored complete --status/--message/--file' (now via cobra flags) - 'spored run-queue <file>', 'spored run-pipeline-stage' - 'spored version' → kept as an explicit subcommand (cobra's --version flag alone would break scripts/install-spored.sh); --version also works Handlers now return errors instead of calling os.Exit directly (except the --check-complete exit-code path, which must os.Exit by contract). Removed the hand-written printHelp and manual flag loops; cobra provides help and parsing. Adds TestCLIContract locking the subcommand names, status --check-complete, complete flags, config get/set/list, and the version subcommand, so the contracts can't silently regress. Existing TestCheckCompleteCode unchanged. Completes the spawn#40 suite-wide flag normalization (spawn, truffle, lagotto, spored).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Final piece of the spawn#40 suite-wide flag normalization (spawn #42, truffle #17, lagotto #17 already merged).
What
sporedparsed args with a hand-rolledswitch os.Args[1]+ manualos.Args[2:]slicing — sharing no flag infrastructure with the other CLIs. Converted to a cobra command tree for consistent parsing, structured help, and the same conventions as spawn/truffle/lagotto.Contracts preserved exactly
spawn shells out to spored and the user-data bootstrap depends on it, so every contract is unchanged — verified against the built binary:
spored(no args)runDaemon(); systemdExecStart)spored status --check-completespored config get/set/listspored reloadspored complete --status/--message/--filespored run-queue <file>,run-pipeline-stagespored version--versionalone would breakscripts/install-spored.sh);--versionworks tooHandlers now return errors instead of calling
os.Exitdirectly — except the--check-completeexit-code path, which mustos.Exitby contract. Removed the hand-writtenprintHelpand manual flag loops (cobra provides both).Test
TestCLIContractlocks the subcommand names,status --check-complete, thecompleteflags,config get/set/list, and theversionsubcommand, so the external surface can't silently regress.TestCheckCompleteCodeunchanged.go build ./...,go vet,go test ./cmd/...green; manually verified daemon mode, check-complete exit 2, config, complete, version.Tracking: spawn#40.