完成表单选项 - <option>:<file>和 - <option>:<possible values =“”>

时间:2015-10-28 18:31:42

标签: zsh zsh-completion

我试图为fsharpi(F#interactive)编写一个完成方法,其中包含以下选项:

--use:<file>              Use the given file on startup as initial input
--debug:{full|pdbonly}    Specify debugging type: full, pdbonly. ('full' is the default and enables attaching a debugger to a running program).
--warn:<n>                Set a warning level (0-5)

我猜这必须与 $ state 一样,与sub-commands类似,但文档是单一的,语言不具有描述性,所以我和#39;没有通过实验和拼凑不同的例子。

对此的解决方案也适用于aspell,它使用等号而不是冒号,例如。

--conf=<str>              main configuration file

1 个答案:

答案 0 :(得分:0)

这是最常见的完成形式之一,_arguments可以轻松处理。请注意,选项中的文字冒号可以用反斜杠引用。这是代码示例:

#compdef command

arguments=(
    '--use\:-:initial input file:_files'
    '--debug\:-:debugging type:(full pbonly)'
    '--warn\:-:warning level:(0 1 2 3 4 5)'
)

_arguments -S $arguments[@]

参考:_arguments in official documentation