feat: add opt-in case- and hyphen-insensitive CLI option matching - #36
Merged
Conversation
bhirsz
force-pushed
the
feat/lenient-cli-names
branch
from
August 31, 2026 11:47
464dabf to
e3b6296
Compare
Add two per-class attributes, `cli_case_insensitive` and `cli_ignore_hyphens` (both default off), that relax long-option matching on the command line so `--variable-file`, `--variablefile` and `--VariableFile` can all resolve to the same option, and flags negate as `--no-statusrc`, `--nostatusrc` or `--No-StatusRc`. Matching is lenient on the command line only: configuration-file keys stay exact (their underscore/hyphen variants remain interchangeable, but case is significant). A normalised fallback name map is built alongside the exact map; options whose names collide once normalised keep working through their exact spelling and are dropped from the fallback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bhirsz
force-pushed
the
feat/lenient-cli-names
branch
from
August 31, 2026 11:50
e3b6296 to
49b0270
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two opt-in, per-class attributes that relax long-option matching on the
command line:
cli_case_insensitive—--VariableFileresolves to--variablefilecli_ignore_hyphens—--variable-fileresolves to--variablefileBoth default to off, so existing behaviour is unchanged unless a tool opts
in. With both enabled,
--variablefile,--variable-file,--VariableFileand--VARIABLE-FILEall resolve to the same option, and a flag can be negated as--no-statusrc,--nostatusrcor--No-StatusRc.Configuration files stay exact
Leniency applies to the command line only. A
[tool.<tool>]table must usethe option's declared name; its underscore/hyphen variants remain interchangeable
(pre-existing behaviour), but case is significant and arbitrary hyphenation is
not accepted. This keeps config files unambiguous and diff-friendly.
How it works
long_normalized_to_attr) is built next to theexact
long_to_attrmap. Lookups try the exact name first, then thenormalised fallback when leniency is enabled (
NameTable.long_attr).cli_case_insensitive) and strips hyphens(when
cli_ignore_hyphens).--no-<name>form (with lenientbase resolution) and, when hyphens are ignorable, the joined
--no<name>form.--foo-barvs--foobar), theshared fallback is dropped — both still work through their exact spellings.
Why
Requested for the Robot Framework CLI migration
(robotframework/robotframework#5773),
whose legacy parser accepted case- and hyphen-insensitive long options. Making
this a confargs feature (rather than pre-processing argv on the tool side) keeps
the tool integration thin and lets other tools opt in too.
Changes
src/confargs/base.py— newcli_case_insensitive/cli_ignore_hyphensclass attributes (documented).
src/confargs/options.py—NameTablegains the normalised fallback map andlong_attr/normalize_barehelpers;resolve_namesbuilds the fallback.src/confargs/cli.py— long-option and negation resolution use lenient lookup.src/confargs/processor.py— passes the class toggles intoresolve_names;eager scanning uses lenient lookup.
tests/test_lenient_names.py— 17 new tests (spellings, negation forms,opt-in-only, single-toggle behaviour, normalised-collision fallback, config
exactness, end-to-end).
README.md/CHANGELOG.md— documented under "Options in depth" and an[Unreleased]Features entry.Validation
uv run ruff check .,uv run ruff format --check .,uv run mypyanduv run pytest -q(308 tests) all pass.