diff --git a/kitty/cli.py b/kitty/cli.py index 119b92680..fcd6a8976 100644 --- a/kitty/cli.py +++ b/kitty/cli.py @@ -451,8 +451,6 @@ def as_type_stub(seq: OptionSpecSeq, disabled: OptionSpecSeq, class_name: str, e t = 'typing.Optional[str]' elif otype == 'list': t = 'typing.Sequence[str]' - elif otype == 'path': - t = 'str' elif otype in ('choice', 'choices'): if opt['choices']: t = 'typing.Literal[{}]'.format(','.join(f'{x!r}' for x in opt['choices'])) @@ -535,8 +533,6 @@ def process_arg(self, alias: str, val: Any = None) -> None: raise SystemExit('{} is not a valid value for the {} option. Valid values are: {}'.format( val, emph(alias), ', '.join(choices))) self.values_map[name] = val - elif typ == 'path': - self.values_map[name] = val elif typ in nmap: f = nmap[typ] try: @@ -616,6 +612,7 @@ def options_spec() -> str: --config -c type=list +completion=type:file ext:conf group:"Config files" {config_help} @@ -627,7 +624,6 @@ def options_spec() -> str: --directory --working-directory -d default=. -type=path completion=type:directory Change to the specified directory when launching. @@ -639,8 +635,7 @@ def options_spec() -> str: --session -type=path -completion=ext:session relative:conf group:"Session files" +completion=type:file ext:session relative:conf group:"Session files" Path to a file containing the startup :italic:`session` (tabs, windows, layout, programs). Use - to read from STDIN. See the :file:`README` file for details and an example. Environment variables are expanded, relative paths are resolved relative @@ -748,8 +743,7 @@ def options_spec() -> str: --watcher -type=path -completion=ext:py relative:conf group:"Watcher files" +completion=type:file ext:py relative:conf group:"Watcher files" This option is deprecated in favor of the :opt:`watcher` option in :file:`{conf_name}.conf` and should not be used. diff --git a/kitty/complete.py b/kitty/complete.py index 15eb09b5f..68163d339 100644 --- a/kitty/complete.py +++ b/kitty/complete.py @@ -386,14 +386,6 @@ def complete_kitty_cli_arg(ans: Completions, opt: Optional[OptionDict], prefix: from kitty.config import option_names_for_completion k = 'Config directives' ans.add_match_group(k, {k+'=': '' for k in option_names_for_completion() if k.startswith(prefix)}, trailing_space=False) - elif dest == 'config': - - def is_conf_file(x: str) -> bool: - if os.path.isdir(x): - return True - return x.lower().endswith('.conf') - - complete_files_and_dirs(ans, prefix, files_group_name='Config files', predicate=is_conf_file) elif dest == 'listen_on': if ':' not in prefix: k = 'Address type' @@ -644,7 +636,7 @@ def complete_file_path(ans: Completions, spec: Dict[str, str], prefix: str, only def complete_path(ans: Completions, opt: OptionDict, prefix: str) -> None: spec = opt['completion'] - t = spec.get('type', 'file') + t = spec['type'] if t == 'file': complete_file_path(ans, spec, prefix) elif t == 'directory': @@ -654,7 +646,7 @@ def complete_path(ans: Completions, opt: OptionDict, prefix: str) -> None: def complete_basic_option_args(ans: Completions, opt: OptionDict, prefix: str) -> None: if opt['choices']: ans.add_match_group(f'Choices for {opt["dest"]}', tuple(k for k in opt['choices'] if k.startswith(prefix))) - elif opt['type'] == 'path': + elif opt['completion'].get('type') in ('file', 'directory'): complete_path(ans, opt, prefix) diff --git a/kitty/launch.py b/kitty/launch.py index 9c767182d..13fa3f4c8 100644 --- a/kitty/launch.py +++ b/kitty/launch.py @@ -201,7 +201,7 @@ def options_spec() -> str: --logo type=path -completion=ext:png group:"PNG images" relative:conf +completion=type:file ext:png group:"PNG images" relative:conf Path to a PNG image to use as the logo for the newly created window. See :opt:`window_logo_path`. Relative paths are resolved from the kitty configuration directory. @@ -228,6 +228,7 @@ def options_spec() -> str: --watcher -w type=list +completion=type:file ext:py relative:conf group:"Python scripts" Path to a Python file. Appropriately named functions in this file will be called for various events, such as when the window is resized, focused or closed. See the section on watchers in the launch command documentation: :ref:`watchers`.