mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
idf.py: Add positional arguments to subcommands
This commit is contained in:
parent
8dc8dd5689
commit
afc30b09bc
14
tools/idf.py
14
tools/idf.py
@ -599,6 +599,13 @@ def init_cli():
|
||||
|
||||
self.callback = wrapped_callback
|
||||
|
||||
class Argument(click.Argument):
|
||||
"""Positional argument"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
names = kwargs.pop("names")
|
||||
super(Argument, self).__init__(names, **kwargs)
|
||||
|
||||
class CLI(click.MultiCommand):
|
||||
"""Action list contains all actions with options available for CLI"""
|
||||
|
||||
@ -630,8 +637,12 @@ def init_cli():
|
||||
|
||||
# Actions
|
||||
for name, action in action_list.get("actions", {}).items():
|
||||
arguments = action.pop("arguments", [])
|
||||
options = action.pop("options", [])
|
||||
|
||||
if arguments is None:
|
||||
arguments = []
|
||||
|
||||
if options is None:
|
||||
options = []
|
||||
|
||||
@ -639,6 +650,9 @@ def init_cli():
|
||||
for alias in [name] + action.get("aliases", []):
|
||||
self.commands_with_aliases[alias] = name
|
||||
|
||||
for argument_args in arguments:
|
||||
self._actions[name].params.append(Argument(**argument_args))
|
||||
|
||||
for option_args in options:
|
||||
option_args["param_decls"] = option_args.pop("names")
|
||||
self._actions[name].params.append(click.Option(**option_args))
|
||||
|
Loading…
Reference in New Issue
Block a user