Repository navigation
Extract shared root command factory - #209
Merged
Merged
Conversation
added 3 commits
March 10, 2026 20:59
Move duplicated cobra setup, flags, Viper init, and metadata commands from lore/root.go and writ/root.go into cli.NewRootCmd(). Each caller now provides only its name, description, default config, and subcommands. Fixes two drift bugs: writ missing DisableAutoGenTag, lore using cmd instead of cmd.Root() in BindFlags (wrong when called from subcommand).
Move duplicated cobra setup, flags, Viper init, and metadata commands from lore/root.go and writ/root.go into cli.NewRootCmd(). Each caller now provides only its name, description, default config, and subcommands. Fixes two drift bugs: writ missing DisableAutoGenTag, lore using cmd instead of cmd.Root() in BindFlags (wrong when called from subcommand).
…/devlore-cli into feature/root-command-factory
David-Noble-at-work
added a commit
that referenced
this pull request
Sep 28, 2026
…ero (#973) * docs(plans): CI lints four of eleven; the gate arrives with its sweep The plan for #964, committed before the work, and the #721 charter's retired status word with it. ci.yaml runs make vet-all, star lint go, make lint-all and star lint shell. It never runs star lint all, markdown, go-style or copyright, and it has no PowerShell step although install.ps1 ships to users. make check runs none of them. The count is 51, not the 33 the issue states. Measured with Test-PowerShell.ps1, the gate CI would actually run rather than PSScriptAnalyzer alone: 30 PSAvoidUsingWriteHost, 9 missing [CmdletBinding()], 4 missing param(), 3 missing shebang, 2 script-level param(), and one each of PSReviewUnusedParameter, PSUseBOMForUnicodeEncodedFile and PSUseSingularNouns. Four of those checks are the gate's own and account for 18 of the 51. Three pull requests, one plan, because the pieces have different blockers. The PowerShell gate and install.ps1 go first: devlore-cli#949's lanes 11 and 21 both edit install.ps1 and are held for it. Starlark is not buildifier's to cover. Ruled 2026-09-28: buildifier is being replaced, and #721 is the replacement. Every defect that shipped in the docker package was syntactically valid Starlark that buildifier parses without complaint. Markdown is measured and the answer is that there is no policy to measure against: 36,857 findings over 464 files, 25,318 of them line-length, against markdownlint's defaults, because no configuration exists anywhere. Phase 3 writes one in the base layer. lint-starlark.md restated its status in the body as `charter`, which is not one of the five and was retired by noblefactor-ops#219. A status in two places is a second copy that drifts, so the body no longer carries one. * fix(ci): the PowerShell gate arrives with its sweep, 51 findings to zero install.ps1 ships to users and was checked by nothing, while noblefactor-ops has had this gate since its #218 and personal since its #216. Phase 2 of #964. The gate runs as three steps of quality-gate, not as a job of its own. This repository's ruleset requires exactly one check, quality-gate, so a separate job could not block a merge whatever it reported -- which ci.yaml already says of the test job beside it: "A gate nobody has watched refuse anything is a claim, not a gate." personal#216 could use a separate job because that repository's ruleset admits one. Test-PowerShell.ps1 and PSScriptAnalyzerSettings.psd1 are the organization's, so the script runs out of a pinned .base checkout rather than being copied here, and the rule set cannot drift between the three repositories. install.ps1, 47 findings: - 30 Write-Host calls go to the stream PowerShell already has for each level: Write-Information for progress, Write-Warning for warnings, Write-Error for failures. Write-Host went to none of them and cannot be captured, so a user whose install failed could not pipe the run to a file or paste a log -- which for an installer run under irm | iex is exactly when a log matters. Separate streams also let a caller silence warnings and keep progress, which one stream carrying text prefixes cannot offer. - Write-Fatal keeps its exit 1 and uses -ErrorAction Continue to do so. The script sets $ErrorActionPreference = Stop, under which a bare Write-Error throws and the exit never runs -- which would change how the installer terminates, and that is #965, another lane's work. This commit puts the message on the error stream and leaves the exit path as it found it. - The color is not replaced. $PSStyle is 7.2 and later and this script must run on Windows PowerShell 5.1, what a fresh Windows machine has (#948). Write-Warning and Write-Error label their own output, so info: and success: are the only prefixes left. - Nine functions gain [CmdletBinding()], four gain param(), and three gain [OutputType] because promoting a function to advanced brings PSUseOutputTypeCorrectly with it. - Get-ApiHeaders becomes Get-ApiHeader, with its call sites. - An em dash in a comment goes rather than the byte-order mark PSUseBOMForUnicodeEncodedFile would otherwise want, which #209 forbids. - Prefix is suppressed, not deleted. It is read by Main -- defaulted to ~/.local, made the bin directory, passed to self install -- across a dynamic-scope boundary the analyzer cannot see. Deleting it would silently drop a documented flag. The two .ps1 test fixtures are fixed rather than excluded. Ruled 2026-09-28: everything is linted, always, no exception without a compelling argument. Both keep doing their job -- the layer-journey and migrate suites pass unchanged. The gate reports 3 checked, 0 with findings.
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
cli.NewRootCmd(cfg RootConfig)factory ininternal/cli/root.goinitRootConfigreplaces duplicatedinitConfigin both packageslore/root.go: 154 → 65 lines (tool-specific flag + subcommands only)writ/root.go: 145 → 56 lines (tool-specific flag + subcommands only)Bug fixes:
DisableAutoGenTag: true(was missing)cmd.Root()inBindFlags(was usingcmd, incorrect when invoked from subcommand)Test plan
make build— all four binaries compilemake test— all tests passmake vet— clean