From 50d5220ed5a2187dbf548d70f3d795a39f7bfd00 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 13 May 2026 09:39:15 +0300 Subject: 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 --- cmd/ior/main.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'cmd') 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() -- cgit v1.2.3