mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
feat(tools): autocomplete @-arguments of idf.py with file names
This commit is contained in:
parent
d37e1cccb6
commit
c7f32f80f4
10
tools/idf.py
10
tools/idf.py
@ -13,6 +13,7 @@
|
||||
# any external libraries here - put in external script, or import in
|
||||
# their specific function instead.
|
||||
import codecs
|
||||
import glob
|
||||
import json
|
||||
import locale
|
||||
import os.path
|
||||
@ -142,6 +143,7 @@ def _safe_relpath(path: str, start: Optional[str]=None) -> str:
|
||||
def init_cli(verbose_output: Optional[List]=None) -> Any:
|
||||
# Click is imported here to run it after check_environment()
|
||||
import click
|
||||
from click.shell_completion import CompletionItem
|
||||
|
||||
class Deprecation(object):
|
||||
"""Construct deprecation notice for help messages"""
|
||||
@ -451,6 +453,14 @@ def init_cli(verbose_output: Optional[List]=None) -> Any:
|
||||
return Action(name=name, callback=callback.unwrapped_callback)
|
||||
return None
|
||||
|
||||
def shell_complete(self, ctx: click.core.Context, incomplete: str) -> List[CompletionItem]:
|
||||
if incomplete.startswith('@'):
|
||||
path_prefix = incomplete[1:]
|
||||
candidates = glob.glob(path_prefix + '*')
|
||||
result = [CompletionItem(f'@{c}') for c in candidates]
|
||||
return result
|
||||
return super(CLI, self).shell_complete(ctx, incomplete) # type: ignore
|
||||
|
||||
def _print_closing_message(self, args: PropertyDict, actions: KeysView) -> None:
|
||||
# print a closing message of some kind,
|
||||
# except if any of the following actions were requested
|
||||
|
Loading…
x
Reference in New Issue
Block a user