![](/img/trans.png)
[英]read multiple words as arguments from "typer" python || how to read a unknown number of strings with spaces from cli using "typer" "python"
[英]Python: How to remove default options on Typer CLI?
我使用Typer和Pillow制作了一个简单的 CLI 来更改图像不透明度,这个程序只有一个选项:不透明度。
但是当我运行python opacity.py --help
它给了我两个 typerCLI 选项:
Options:
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified
shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified
shell, to copy it or customize the
installation.
--help Show this message and exit.
有没有办法禁用它? 我在文档上没有找到。
我今天遇到了同样的问题,除了这个问题我什么也找不到,所以我在源代码中找到了 Typer 如何自动在应用程序中添加这一行,所以我发现了这一点,当Typer初始化自身时,它会自动将add_completion
设置为 True
class Typer:
def __init__(add_completion: bool = True)
所以当你初始化你的应用程序时,你可以添加这个
app = typer.Typer(add_completion=False)
这是添加add_completion=False
后的样子
Usage: main.py [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.