Skip to content

Address the complexity of main() - #47

Open
udf2457 wants to merge 1 commit into
tillitis:mainfrom
udf2457:cleanmain
Open

Address the complexity of main()#47
udf2457 wants to merge 1 commit into
tillitis:mainfrom
udf2457:cleanmain

Conversation

@udf2457

@udf2457 udf2457 commented Jul 2, 2026

Copy link
Copy Markdown

As a controversial disclosure, this PR is LLM assisted. I am not a vibecoder, but "clean up main()" seemed to me to be a focused enough task to try out, and given #43 has been open since March ...

This is what the LLM spat out and it seems like a reasonable attempt.

  1. Struct-based flags – all flags live in an opts struct, eliminating the sea of local pflag variables in main.
  2. Centralized validation – required flags per command and USS flag rules are checked in one place (or single helpers), not duplicated inside case blocks.
  3. defer signer.Close() – the signer is closed automatically when runGetKey or runSign return, removing the manual signer.Close() calls before every os.Exit.
  4. Default handling – the .sig file default is set in one helper (setDefaults), not twice.
  5. main() is purely dispatch – parse → validate → run → exit. All business logic lives in runGetKey, runSign, and runVerify.

An attempt to address the complexity of main() as originally reported by gocyclo and maintidx tests in golangci-lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant