简体   繁体   English

gengetopt:多个参数以空格分隔,而不是逗号

[英]gengetopt: Multiple arguments split with space, not comma

When specifying an option as 当指定一个选项为

option "foo" f "" string optional multiple(1-)

gengetopt correctly builds up the array foo_args when called as: gengetopt正确构建为以下形式的数组foo_args

./a.out -f A -f B -f C        # {"A", "B", "C"}
./a.out -f A,B,C              # {"A", "B", "C"}

But this only grabs the first "A", and considers "B" and "C" to be unnamed 但这只会获取第一个“ A”,并认为“ B”和“ C”未命名

./a.out -f A B C              # {"A"}

I'm not using --unnamed-opts , because I don't have any unnamed arguments. 我没有使用--unnamed-opts ,因为我没有任何未命名的参数。 I'd like to support that style, because it seems more common… is that 我想支持这种风格,因为它似乎更常见……是 easily 容易 possible? 可能?

您可以尝试将引号括在以空格分隔的列表项周围,如下所示: -f "ABC"并进行额外的解析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM