cli: Add possibility to specify aliases for CLI option - #910
Conversation
Thank you for contributing to the Leapp project!Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergeable.
To launch regression testing public members of oamg organization can leave the following comment:
Please open ticket in case you experience technical problem with the CI. (RH internal only) Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please consider rerunning the CI by commenting leapp-ci build (might require several comments). If the problem persists, contact leapp-infra. |
fab60aa to
65676c2
Compare
| def add_option(self, name, short_name='', help='', # noqa; pylint: disable=redefined-builtin | ||
| is_flag=False, inherit=False, value_type=str, wrapped=None, action=None, metavar=None, | ||
| choices=None, default=None): | ||
| def add_option( # noqa; pylint: disable=redefined-builtin, too-many-arguments |
There was a problem hiding this comment.
The argument list is definitely long, maybe we should consider replacing the optional args with **kwargs at this point. I left it as it is for now.
|
is there a ticket behind this change? |
pirat89
left a comment
There was a problem hiding this comment.
missing bump of leapp-framework
@karolinku No dedicated one, it's a prerequisite for this https://issues.redhat.com/browse/RHEL-110563. That's why I didn't add it in the descriptions. |
Right, completely missed that, thanks. |
well, still it would be nice to have a note about it. e.g. |
| if len(short_name) != 1: | ||
| raise CommandDefinitionError("Short name should be one letter only") | ||
| names.insert(0, '-' + short_name) | ||
| if aliases: |
There was a problem hiding this comment.
maybe it would be good to add validation if aliases is a list and alias a string?
There was a problem hiding this comment.
Well it's not a bad idea, but we don't validate any other types. E.g. if you pass 1 to name it fails too.
65676c2 to
f3522f9
Compare
|
/rerun |
|
/packit copr-build |
2951ffa to
4dd038d
Compare
|
Squashed commits, from my side it's ready to merge :). |
4dd038d to
fb1e9c3
Compare
|
Added the bump of framework version to the commit message. |
The existing 'name' and 'short_name' parameters are kept as is for backwards compatibility. Also a dest parameter is added for specifying the name of the attribute to be added to the parsed args object. The change is backwards compatible, bump framework-version from 6.1 to 6.2. Jira: RHEL-110563 (related)
fb1e9c3 to
05f5acd
Compare
|
/rerun |
1 similar comment
|
/rerun |
|
/packit retest-failed |
|
/rerun |
The existing 'name' and 'short_name' parameters are kept as is for backwards compatibility.
Also a dest parameter is added for specifying the name of the attribute to be added to the parsed args object.
The change is backwards compatible, bump the
framework-versionto 6.2.Jira: RHEL-110563 (related)
Example help text:
The alias is listed after the
nameand the argument "hint" (TARGET_VERSION) is created fromdestwhich istarget_version.The option is defined like this: