Skip to content

feat: inline xflag package and improve ParseToEnd#7

Merged
mfridman merged 1 commit intomainfrom
mf/inline-xflag
Feb 16, 2026
Merged

feat: inline xflag package and improve ParseToEnd#7
mfridman merged 1 commit intomainfrom
mf/inline-xflag

Conversation

@mfridman
Copy link
Collaborator

@mfridman mfridman commented Feb 16, 2026

This PR inlines the github.com/mfridman/xflag dependency into the repository as the xflag/ sub-package, removing the external module dependency. While doing so, two improvements were made to ParseToEnd:

  1. The reflect + unsafe hack used to set the FlagSet's internal args field was replaced with f.Parse(append([]string{"--"}, args...)), which achieves the same result by leveraging the standard library's -- terminator behavior.
  2. The -- delimiter is now stripped from positional args, consistent with the standard library's behavior.

Test coverage was expanded from 8 to 15 cases (100% statement coverage), including interleaved space-separated flags, single-dash syntax, standalone -, duplicate flags, and the -- terminator edge cases.

@mfridman mfridman merged commit 2382160 into main Feb 16, 2026
2 checks passed
@mfridman mfridman deleted the mf/inline-xflag branch February 16, 2026 15:44
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