Use a nicer decorator for functions that only need to be run once

This commit is contained in:
Kovid Goyal
2021-02-05 10:40:52 +05:30
parent 726d736aac
commit fe07306ff1
11 changed files with 67 additions and 31 deletions

View File

@@ -21,9 +21,10 @@ from .rc.base import (
RemoteCommand, all_command_names, command_for_name,
display_subcommand_help, parse_subcommand_cli
)
from .types import run_once
@lru_cache(maxsize=2)
@run_once
def match_commands() -> Tuple[str, ...]:
all_commands = tuple(sorted(x.replace('_', '-') for x in all_command_names()))
return tuple(sorted(all_commands + ('exit', 'help', 'quit')))