我如何接受 scopt 中未标记的参数?

How can I accept an unlabeled argument in scopt?

我正在使用 scopt 处理命令行参数,并希望接受 blind/unlabeled 参数。让我们以一个超级简单、熟悉的 'ls' 命令为例:

ls [<selector>] [options]

where options is just one: --tree

所以使用示例可以是:

ls
ls --tree
ls . --tree
ls /foo/bar
ls /foo/bar --tree

scopt 库可以很容易地处理这些选项,并且有一些定义为命令的东西(即如果 ls 有某种辅助模式),但我不明白我如何接受一个可选字符串(选择器)w/o 前面的选项标签。

我的参数 (arg) 和选项 (opt) 倒过来了。他们应该是:

ls --tree /foo/bar

使用这个标准,scopt 已经用 arg 指令做到了这一点。