提交 cb72868a 作者: Matt Bell 提交者: Juan Batiz-Benet

commands: Fixed parser argument bug (TODO: better test coverage for command parsers)

上级 b6aad53d
......@@ -132,6 +132,8 @@ func parseArgs(stringArgs []string, cmd *cmds.Command) ([]interface{}, error) {
// skip optional argument definitions if there aren't sufficient remaining values
if len(stringArgs)-j <= lenRequired && !argDef.Required {
continue
} else if argDef.Required {
lenRequired--
}
if j >= len(stringArgs) {
......
......@@ -60,6 +60,8 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
// skip optional argument definitions if there aren't sufficient remaining values
if valCount <= lenRequired && !argDef.Required {
continue
} else if argDef.Required {
lenRequired--
}
if argDef.Type == cmds.ArgString {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论