Skip to content

Share the interspersed flag parser between subenum and wordlist-gen #136

Closed

Description

@TMHSDigital

What

parseInterspersed and endsWithTerminator exist twice: in main.go and, since #133, in tools/wordlist-gen.go. Both are package main, so they could not import each other.

How

  1. Move the two functions into a small package, for example internal/cliargs, as cliargs.Parse(fs *flag.FlagSet, args []string) ([]string, error).
  2. Use it from both programs and delete the copies.
  3. Move or add the tests for flags after positionals and the -- terminator (see main_test.go and tools/wordlist-gen_test.go).

Done when

One implementation, used by both programs, with its own tests; go test ./... passes.

Activity

  1. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in d6d4954: the two identical copies of parseInterspersed/endsWithTerminator in main.go and tools/wordlist-gen.go are now one cliargs.Parse in internal/cliargs (moved verbatim, so behaviour is unchanged). Verified with the existing TestParseFlagsInterspersed/TestParseFlagsInvalidAfterDomain and wordlist-gen terminator tests, new table tests in internal/cliargs (96% coverage), a new TestRunInterspersedFlags for wordlist-gen, and the full go test -race ./....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions