0

我正在尝试为 fsharpi(F# 交互式)编写一个完成方法,它具有如下选项:

--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,但是文档是单一的,并且语言不是很具有描述性,所以我没有通过实验和拼接不同的示例来获得任何结果。

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

--conf=<str>              main configuration file
4

1 回答 1

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在官方文档中。

于 2015-10-28T19:31:43.720 回答