CommandLineParser - 多次使用相同的 switch/flag
CommandLineParser - Use the same switch/flag multiple times
使用 CommandLineParser NuGet,当我 运行 我的应用程序带有这样的选项时。
myapplication.exe --searchfolder "c:\my great path\"
如何多次使用该选项?比如我要传入两个文件夹...
- "c:\我的伟大道路"
- "c:\我的另一条伟大道路"
目前,对于给定的单一路径,我是这样使用它的...
if (options.Verbose)
{
m_Verbose = true;
Console.WriteLine("Verbose mode on.");
}
if (options.SearchFolder != null && options.SearchFolder != "")
{
Console.WriteLine("Searching folder '{0}'...", options.SearchFolder);
}
你可能想使用这样的东西:
class Options
{
[Option('r', "read", Required = true, HelpText = "Input files to be processed.")]
public IEnumerable<string> InputFiles { get; set; }
这里查看官网fiddle:https://dotnetfiddle.net/wrcAxrIEnumerable
用法
使用 CommandLineParser NuGet,当我 运行 我的应用程序带有这样的选项时。
myapplication.exe --searchfolder "c:\my great path\"
如何多次使用该选项?比如我要传入两个文件夹...
- "c:\我的伟大道路"
- "c:\我的另一条伟大道路"
目前,对于给定的单一路径,我是这样使用它的...
if (options.Verbose)
{
m_Verbose = true;
Console.WriteLine("Verbose mode on.");
}
if (options.SearchFolder != null && options.SearchFolder != "")
{
Console.WriteLine("Searching folder '{0}'...", options.SearchFolder);
}
你可能想使用这样的东西:
class Options
{
[Option('r', "read", Required = true, HelpText = "Input files to be processed.")]
public IEnumerable<string> InputFiles { get; set; }
这里查看官网fiddle:https://dotnetfiddle.net/wrcAxrIEnumerable
用法