summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 09:39:15 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 09:39:15 +0300
commit50d5220ed5a2187dbf548d70f3d795a39f7bfd00 (patch)
tree44647a70d126d789a539ddd38cc3986fcf7e61c9 /cmd
parente9c747c607e14d8b8f69547aa3c0f3b079c20796 (diff)
replace global flags singleton with Parse() returning Config value
Remove the global atomic.Pointer[Config], sync.Once, and parseErr fields from the flags package. Parse() now returns (Config, error) directly, eliminating all global-state accessors (Get, SetPidFilter, SetTidFilter, SetTUIExportEnable, setCurrent, updateCurrent). The internal parse logic is factored into parseFromFlagSet so tests can inject a fresh FlagSet without touching os.Args or package-level state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ior/main.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/cmd/ior/main.go b/cmd/ior/main.go
index 9c5bac1..d6326cc 100644
--- a/cmd/ior/main.go
+++ b/cmd/ior/main.go
@@ -18,15 +18,14 @@ func main() {
os.Exit(2)
}
- // Parse command-line flags
- if err := flags.Parse(); err != nil {
+ // Parse command-line flags; Parse returns the Config directly so there is no
+ // global singleton to read from after this point.
+ cfg, err := flags.Parse()
+ if err != nil {
fmt.Printf("Failed to parse flags: %v\n", err)
os.Exit(2)
}
- // flags.Get() is called here at the CLI boundary so internal code never reads the singleton.
- cfg := flags.Get()
-
// Handle -version: print the banner plus version and exit.
if cfg.ShowVersion {
flags.PrintVersion()