Skip to content

feat(cli): keep old flag spellings working when an option is renamed - #18

Merged
MrKevinWeiss merged 3 commits into
masterfrom
feat/cli-renamed-argument
Aug 11, 2026
Merged

feat(cli): keep old flag spellings working when an option is renamed#18
MrKevinWeiss merged 3 commits into
masterfrom
feat/cli-renamed-argument

Conversation

@MrKevinWeiss

Copy link
Copy Markdown
Collaborator

Split out of the review of lobaro/python-lob-nrf-sx-gw4#50, which had grown a
private _resolve_deprecated_arg helper. lob-cord and lob-at rename options
too, so this belongs here rather than in one tool.

add_renamed_argument(parser, --log-level, deprecated=--loglevel, default=WARNING)

The old spelling writes to the same dest as the new one, so it is resolved
during parsing. Nothing downstream has to know it exists and there is no fixup
step after parse_args. It is hidden from --help and warns when used, as a
DeprecationWarning for tests and as a log record so the user actually sees it
before logging is configured.

Handles options that take a value, flags such as store_true, short flags, and
an option renamed more than once. type and choices are applied to the old
spelling as well, so it is not a hole in the interface.

Python 3.13 has add_argument(deprecated=True) which would replace the warning
half of this, but these packages support 3.10.

Needs a release once merged; lobaro/python-lob-nrf-sx-gw4#50 pins lob-hlpr>=0.0.11.

MrKevinWeiss and others added 3 commits August 11, 2026 10:22
Several tools rename options and have to keep the old spelling alive. Each was
about to grow its own way of doing that, so put it here once.

The old spelling writes to the same destination as the new one, so nothing
downstream needs to know it exists and no post-parse fixup step is needed. It is
hidden from --help and warns when used, as a DeprecationWarning for tests and as
a log record so the user sees it even before logging is configured.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MrKevinWeiss
MrKevinWeiss merged commit 5001bed into master Aug 11, 2026
6 checks passed
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