命令行解析库 - 布尔参数 [英] Command Line Parser Library - Boolean Parameter
问题描述
我尝试将布尔参数传递到一个控制台应用程序和处理与命令行解析库值
[选项(C,closeWindow,必需=真,帮助文件=关闭窗口。)
公共BOOL CloseWindow {搞定;组; }
我试图传递参数为
-c虚假
-c假
-c假
-...
有没有差异,每个尝试,我得到真实
的值。
谁能告诉我,我怎么也得传递参数,以获得布尔假
价值?
要避免可能的询问,有哪些是正确传递字符串选项:
[选项(' S',系统所需= TRUE,帮助文件=任何帮助文本)]
公共字符串系统{搞定;组; }
您不需要添加真
或假
。使用 -c
将评估为真
。不使用它会评估为假
。某处的文档中有一个与 -v
详细输出的例子。但我现在不能找到它。我猜必需=真
是没有必要的布尔选项。
I try to pass a boolean parameter to a console application and process the value with the Command Line Parser Library.
[Option('c', "closeWindow", Required = true, HelpText = "Close the window.")]
public bool CloseWindow { get; set; }
I tried to pass the parameter as
-c false
-c False
-c "false"
-...
There are no differences, on each try I get "true"
as value.
Can anyone tell me how I have to pass the parameter to get the boolean false
value?
To avoid possible asks, there is a string option which is passed correctly:
[Option('s', "system", Required = true, HelpText = "Any help text")]
public string System { get; set; }
You don't need to add True
or False
. Using -c
will evaluate to True
. Not using it will evaluate to False
. Somewhere in the documentation there is an example with -v
for verbose output. But I can't find it right now. I guess Required=true
is not necessary for Boolean options.
这篇关于命令行解析库 - 布尔参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!