本文整理汇总了C#中CommandLineParser.Has方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.Has方法的具体用法?C# CommandLineParser.Has怎么用?C# CommandLineParser.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.Has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
var helpMessage = ResourceContentLoader.LoadText("Help.txt", Assembly.GetExecutingAssembly());
var clp = new CommandLineParser(args, helpMessage);
if (clp.Has("makenuspec"))
{
MakeNuspec(clp["makenuspec"]);
}
if (clp.Has("nuget"))
{
_nugetExe = clp["nuget"];
}
if (clp.Has("pack", "nuget", "nuspec", "sourceDir", "destDir", "dlls"))
{
BuildNuget(clp["nuspec"], clp["sourceDir"], clp["destDir"], clp["dlls"]);
}
}
示例2: Main
static void Main(string[] args)
{
var helpMessage = ResourceContentLoader.LoadText("Help.txt", Assembly.GetExecutingAssembly());
var clp = new CommandLineParser(args, helpMessage);
var runner = new NodeCsService();
if (clp.Has("service"))
{
if (clp.Has("serviceSHOULDSTART REALLY"))
{
var servicesToRun = new ServiceBase[] { };
ServiceBase.Run(servicesToRun);
}
else { throw new NotImplementedException(); }
}
else
{
runner.Run(args,helpMessage);
while (true)
{
Shared.NodeRoot.Write();
var result = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(result))
{
if (result.Trim().ToLowerInvariant() == "close")
{
break;
}
else
{
if (!runner.Execute(result))
{
break;
}
}
}
}
Shared.NodeRoot.WriteLine("Stopping.");
runner.Terminate();
Shared.NodeRoot.WriteLine("Stopped.");
}
}
示例3: ItShouldBePossibleToCheckForValuesPresence
public void ItShouldBePossibleToCheckForValuesPresence()
{
const string helpString = "help";
var args = new[] { "-test", "-gino","-pino","pinoValue" };
var eb = new ExitBehaviour();
var commandLineParser = new CommandLineParser(args, helpString, eb);
Assert.IsTrue(commandLineParser.Has(new []{"test","gino"}));
Assert.IsFalse(commandLineParser.Has(new[] { "test", "fake" }));
Assert.IsFalse(commandLineParser.Has(new[] { "fluke", "fake" }));
Assert.IsTrue(commandLineParser.HasAllOrNone(new[] { "test", "gino" }));
Assert.IsFalse(commandLineParser.HasAllOrNone(new[] { "test", "fake" }));
Assert.IsTrue(commandLineParser.HasAllOrNone(new[] { "fluke", "fake" }));
Assert.IsFalse(commandLineParser.HasOneAndOnlyOne(new[] { "test", "gino" }));
Assert.IsTrue(commandLineParser.HasOneAndOnlyOne(new[] { "test", "fake" }));
Assert.IsFalse(commandLineParser.HasOneAndOnlyOne(new[] { "fluke", "fake" }));
Assert.AreEqual(0, eb.ShowHelpCalled);
}