本文整理汇总了C#中System.CommandLine.GetOptionSrting方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLine.GetOptionSrting方法的具体用法?C# CommandLine.GetOptionSrting怎么用?C# CommandLine.GetOptionSrting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CommandLine
的用法示例。
在下文中一共展示了CommandLine.GetOptionSrting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
// Command Line Arguments
CommandLine args = new CommandLine();
// Print Prompts
Console.WriteLine(Constants.HeadPrompt);
if (args.Count == 0)
{
Console.WriteLine(Constants.UsagePrompt);
return;
}
// Check Arguments
CommandLine.Argument command = args[0];
StringComparer comparer = StringComparer.InvariantCultureIgnoreCase;
if (comparer.Equals(command.Name, "scan"))
{
String dir = args.GetOptionSrting("dir", String.Empty);
String dump = args.GetOptionSrting("dump", "dump.xml");
using (var writer = XmlWriter.Create(dump, new XmlWriterSettings {Indent = true}))
{
Scan(dir, writer);
writer.Flush();
}
}
else if (comparer.Equals(command.Name, "apply"))
{
String dir = args.GetOptionSrting("dir", String.Empty);
String dump = args.GetOptionSrting("dump", "dump.xml");
XDocument doc = XDocument.Parse(File.ReadAllText(dump));
Apply(dir, doc);
}
else if (comparer.Equals(command.Name, "clone"))
{
String origin = args.GetOptionSrting("origin", "");
String destination = args.GetOptionSrting("destination");
if (destination == null)
{
Console.Error.WriteLine("ERROR: You must specify a clone destination!");
return;
}
using (var stream = new MemoryStream())
{
var writer = new XmlTextWriter(stream, Encoding.UTF8);
Scan(origin, writer);
writer.Flush();
stream.Position = 0;
var reader = new StreamReader(stream, Encoding.UTF8);
String xml = reader.ReadToEnd();
XDocument doc = XDocument.Parse(xml);
Apply(destination, doc);
}
}
else
{
Console.Error.WriteLine("ERROR: RenEx.Clone could not recognize the command \"{0}\".", command.Name);
}
}