Wire up completion for rc command options

This commit is contained in:
Kovid Goyal 2022-09-16 20:53:05 +05:30
parent 3a8bab90dc
commit 3bf20594b7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,8 @@ def generate_completion_for_rc(name: str) -> None:
print(f'{name}.Description = "{serialize_as_go_string(cmd.short_desc)}"')
for x in cmd.args.as_go_completion_code(name):
print(x)
for opt in rc_command_options(name):
print(opt.as_completion_option(name))
def generate_completions_for_kitty() -> None:

View File

@ -71,6 +71,7 @@ def completion(self: TestCompletion, tdir: str):
env = os.environ.copy()
env['PATH'] = os.path.join(tdir, 'bin')
env['HOME'] = os.path.join(tdir, 'sub')
env['KITTY_CONFIG_DIRECTORY'] = os.path.join(tdir, 'sub')
cp = subprocess.run(
[kitty_tool(), '__complete__', 'json'],
check=True, stdout=subprocess.PIPE, cwd=tdir, input=json.dumps(all_argv).encode(), env=env
@ -124,6 +125,11 @@ def completion(self: TestCompletion, tdir: str):
add('kitty -1d', all_words('-1d'))
add('kitty --directory=', all_words('--directory=bin/', '--directory=sub/'))
add('kitty --start-as=m', all_words('--start-as=minimized', '--start-as=maximized'))
add('kitty @launch --ty', has_words('--type'))
add('kitty @launch --type ', has_words('window', 'background', 'overlay'))
add('kitty @launch --cwd ', has_words('current', 'oldest', 'last_reported'))
add('kitty @launch --logo ', all_words('exe-not3.png'))
add('kitty @launch --logo ~', all_words('~/exe-not3.png'))
for cmd, tests, result in zip(all_cmds, all_tests, run_tool()):
self.current_cmd = cmd