8000 Add cli support for choices and default by fernflower · Pull Request #734 · oamg/leapp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add cli support for choices and default #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000 Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion leapp/utils/clicmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def _add_opt(self, *args, **kwargs):
self._options.append((args, kwargs, internal))

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):
is_flag=False, inherit=False, value_type=str, wrapped=None, action=None, metavar=None,
choices=None, default=None):
"""
Add an option

Expand All @@ -220,6 +221,10 @@ def add_option(self, name, short_name='', help='', # noqa; pylint: disable=rede
:param metavar: Changes the display name of arguments in generated help messages.
It has no influence on the attribute name from the generated arguments namespace.
:type metavar: str
:param choices: range of values that the argument is allowed to take
:type choices: list
:param choices: default value of the argument if nothing is specified
:type choices: str
:return: self
"""
name = name.lstrip('-')
Expand All @@ -238,6 +243,10 @@ def add_option(self, name, short_name='', help='', # noqa; pylint: disable=rede
kwargs['type'] = value_type
if metavar:
kwargs['metavar'] = metavar
if choices:
kwargs['choices'] = choices
if default:
kwargs['default'] = default
self._add_opt(*names, help=help, # noqa; pylint: disable=redefined-builtin
action=action, internal={'wrapped': wrapped, 'inherit': inherit}, **kwargs)
return self
Expand Down
0