Skip to content

feat(getopt): add option to permit partial name matches for long flags#32

Merged
brandon1024 merged 1 commit into
mainfrom
partial-flags
Apr 12, 2026
Merged

feat(getopt): add option to permit partial name matches for long flags#32
brandon1024 merged 1 commit into
mainfrom
partial-flags

Conversation

@brandon1024

Copy link
Copy Markdown
Owner

This revision introduces a new field PosixFlagSet.RelaxedParsing which relaxes the parser to permit partial name matches for long flags. For example, when enabled, '--al' would match the flag '--algorithm', assuming no other flag names have the prefix 'al'.

An associated ExecuteOption was added to enable this functionality. By default, relaxed parsing is disabled.

Improved test coverage of PosixFlagSet.

This revision also fixes a few bugs in package getopt. When a new flag set is created with NewPosixFlagSet, the wrong usage renderer was being called when flag parsing fails. Additionally, long-format flags were incorrectly matching short flags (e.g. '--a' accepted for flag 'a', but should not match). These bugs have been corrected and tests have been added.

This revision introduces a new field PosixFlagSet.RelaxedParsing which
relaxes the parser to permit partial name matches for long flags. For
example, when enabled, '--al' would match the flag '--algorithm',
assuming no other flag names have the prefix 'al'.

An associated ExecuteOption was added to enable this functionality. By
default, relaxed parsing is disabled.

Improved test coverage of PosixFlagSet.

This revision also fixes a few bugs in package getopt. When a new flag
set is created with NewPosixFlagSet, the wrong usage renderer was being
called when flag parsing fails. Additionally, long-format flags were
incorrectly matching short flags (e.g. '--a' accepted for flag 'a', but
should not match). These bugs have been corrected and tests have been
added.
@brandon1024 brandon1024 merged commit f03295f into main Apr 12, 2026
1 check passed
@brandon1024 brandon1024 deleted the partial-flags branch April 12, 2026 17:06
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