且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python click app失败,并显示“缺少参数".但找不到问题

更新时间:2023-11-22 10:13:16

您的帮助解析问题是click试图首先填充startdate endate directory参数.

Your help parsing problem is that click is attempting to fill in the startdate endate directory arguments first.

因此,您的simplerequest --help填写前两个,然后抱怨缺少第三个(directory).

So your simplerequest --help fills in the first two and then it complains that the third (directory) is missing.

通常,命令(simplerequest)将是第一个参数.然后,您可以在前面添加可选的args,因为click可以轻松将其与命令区分开.

Usually the command (simplerequest) would be the first argument. You could then add optional args before, since click can easily distinguish those from the command.

或者您也可以强制单击以将第一个arg视为有效命令并进行帮助,但这是非标准的,并且需要一些代码.此外,尽管它们很容易区分,但它会排除命令名称作为开始日期.

Or you could coerce click to see the first arg as a valid command and do the help anyways, but this is non-standard and would require some code. Also it would preclude the command name being the start date, although they are likely easily differentiated.