本文整理汇总了C#中OptionSet.WriteOptionDescriptions方法的典型用法代码示例。如果您正苦于以下问题:C# OptionSet.WriteOptionDescriptions方法的具体用法?C# OptionSet.WriteOptionDescriptions怎么用?C# OptionSet.WriteOptionDescriptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionSet
的用法示例。
在下文中一共展示了OptionSet.WriteOptionDescriptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParsedArguments
public ParsedArguments(string[] args) {
var p = new OptionSet {
{"sum", "If set Sum will be calculated", _ => _SumValues = true},
{"max", "If set show Max value", _ => _MaxValue = true},
{"min", "If set show Min value", _ => _MinValue = true},
{"dir=", "Output directory", dir => _OutputDirectory = GetValidPath(dir)}, {
"count=", "Count of items to be generated. This value is mandatory.", count => {
if (!_CountIsSet && int.TryParse(count, out _Count) && _Count > 0) {
_CountIsSet = true;
}
}
}
};
p.Parse(args);
if (!ArgsAreValid) {
Trace.WriteLine("Parameter args does not contain valid value for count.");
using (var stringWriter = new StringWriter()) {
p.WriteOptionDescriptions(stringWriter);
_ErrorMessage = stringWriter.ToString();
}
}
}
示例2: ParseArguments
public static Options ParseArguments(string[] args)
{
var options = new Options();
var argParser = new OptionSet() {
{ "i=", "Time to Live.", (int arg) => { options.TTL = arg; } },
{ "l=", "Send buffer size.", (int arg) => { options.BufferSize = arg; } },
{ "w=", "Timeout in milliseconds to wait for each reply.", (int arg) => { options.TimeoutLength= TimeSpan.FromMilliseconds(arg); } },
{ "h|help", "Show this message.", arg => { options.Help = (arg != null); } },
{ "V|version", "Show version info.", arg => { options.Version = (arg != null); } }
};
try
{
options.Args.AddRange(argParser.Parse(args));
}
catch (OptionException e)
{
Console.Error.WriteLine(e.Message);
WriteUsage(Console.Error);
argParser.WriteOptionDescriptions(Console.Error);
throw new ArgumentException();
}
if (options.Version)
{
WriteVersionInfo(Console.Error);
throw new ArgumentException();
}
if (options.Args.Count < 1)
{
WriteUsage(Console.Error);
argParser.WriteOptionDescriptions(Console.Error);
throw new ArgumentException();
}
return options;
}
示例3: Main
static int Main(string[] args)
{
var exeName = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
var showHelp = false;
int exitCode = 0;
var p = new OptionSet
{
"Copyright (C) 2011-2015 Silicon Studio Corporation. All Rights Reserved",
"Xenko Effect Compiler Server - Version: "
+
String.Format(
"{0}.{1}.{2}",
typeof(Program).Assembly.GetName().Version.Major,
typeof(Program).Assembly.GetName().Version.Minor,
typeof(Program).Assembly.GetName().Version.Build) + string.Empty,
string.Format("Usage: {0}", exeName),
string.Empty,
"=== Options ===",
string.Empty,
{ "h|help", "Show this message and exit", v => showHelp = v != null },
};
try
{
var commandArgs = p.Parse(args);
if (showHelp)
{
p.WriteOptionDescriptions(Console.Out);
return 0;
}
// Make sure path exists
if (commandArgs.Count > 0)
throw new OptionException("This command expect no additional arguments", "");
var effectCompilerServer = new EffectCompilerServer();
effectCompilerServer.TryConnect("127.0.0.1", RouterClient.DefaultPort);
// Forbid process to terminate (unless ctrl+c)
while (true)
{
Console.Read();
Thread.Sleep(100);
}
}
catch (Exception e)
{
Console.WriteLine("{0}: {1}", exeName, e);
if (e is OptionException)
p.WriteOptionDescriptions(Console.Out);
exitCode = 1;
}
return exitCode;
}
示例4: runRfb
private static void runRfb(object arg)
{
var args = (string[]) arg;
var setup = new BuilderSetup();
var showHelp = false;
var options =
new OptionSet
{
{"b|build=", "The build script to run", v => setup.BuildFile = v},
{"o|output=", "Instead of building, write the XML MSBuild script to the specified file", v => setup.OutputXml = v},
{"t|target=", "The target to execute", v => setup.Target = v},
{"p|property=", "Properties you want to pass into the script", v => setup.Property = v},
{"l|logger=", "Fully qualified typename to a logger you want to use. It must implement the Microsoft.Framework.Build.ILogger interface and have a parameterless constructor.", v => setup.LoggerType = v},
{"h|help", "Shows the usage help", v => showHelp = true}
};
try
{
options.Parse(args);
if (showHelp)
{
options.WriteOptionDescriptions(Console.Out);
goto end;
}
setup.Validate();
using (var runner = new BuildRunner(setup))
runner.Run();
}
catch (OptionException x)
{
Console.WriteLine("The options to rfb were not understood: {0}", x.Message);
options.WriteOptionDescriptions(Console.Out);
}
catch (ValidationException x)
{
Console.WriteLine("The options to rfb are not sufficient to get running: {0}", x.Message);
Console.WriteLine(x.Message);
options.WriteOptionDescriptions(Console.Out);
}
catch (FileNotFoundException x)
{
Console.WriteLine("File {0} was not found", x.FileName);
}
catch (Exception x)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Unhandled exception:");
Console.WriteLine("{0} - {1} at {2}", x.GetType().Name, x.Message, x.StackTrace);
Console.ResetColor();
}
end:
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("rfb done.");
Console.ResetColor();
}
示例5: Main
static void Main(string[] args)
{
var config = new Config();
var p = new OptionSet() {
{ "s|source=", "the source {dir} of the templated project.",
v => config.SourceDirectory = v },
{ "d|destination=",
"the destination {dir} of the outputted NuGet directories",
v => config.DestinationDirectory = v },
{ "c|config=", "the config {dir} which contains your nuspec files.",
v => config.ConfigDirectory = v },
{ "h|help", "show this message and exit",
v => config.ShowHelp =( v != null )},
{ "x|execute=", "execute {NuGet.exe} when creation is complete",
v => config.ExecutePath = v }
};
List<string> extra;
try
{
extra = p.Parse(args);
DisplayBanner();
Console.ForegroundColor = ConsoleColor.Red;
if (config.IsValid() == false)
{
config.ShowHelp = true;
}
Console.ResetColor();
if (config.ShowHelp)
{
p.WriteOptionDescriptions(Console.Out);
return;
}
var factory = new PackageFactory();
factory.Build(config);
}
catch (OptionException e)
{
Console.Write("OnRamper: ");
p.WriteOptionDescriptions(Console.Out);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message);
Console.ResetColor();
return;
}
}
示例6: Main
public static void Main(string[] args)
{
var libs = new List<Assembly> ();
var opts = new OptionSet ();
opts.Add ("r=", "load extra {ASSEMBLY}",
x => {
try {
libs.Add (System.Reflection.Assembly.LoadFile (x));
} catch (System.IO.FileNotFoundException) {
Console.Error.WriteLine ("Error: no such assembly file " + x);
System.Environment.Exit (1);
} catch (Exception e) {
Console.Error.WriteLine ("Error: " + e.Message);
System.Environment.Exit (1);
}
});
opts.Add ("help", "print this message",
x => {
Console.WriteLine ("Usage: xamlpreviewer [OPTIONS] [FILE.xaml]");
Console.WriteLine ();
opts.WriteOptionDescriptions (Console.Out);
Console.WriteLine ();
System.Environment.Exit (1);
});
var remain = opts.Parse (args);
string file = null;
if (remain.Count > 0)
file = remain [0];
Start (file, libs);
}
示例7: GetParameters
static Core.Parameters GetParameters(IEnumerable<string> args)
{
string templateRoot = null;
string outputRoot = null;
string templateFile = null;
string outputFile = null;
var shopHelp = false;
var copyAssets = true;
var copyFile = true;
var options = new OptionSet
{
{"t|template=", "The template's root folder.", v => templateRoot = v},
{"o|output=", "The output folder where static site is generated.", v => outputRoot = v},
{"tf|templatefile=", "The template's file name. Default: index.cshtml.", v => templateFile = v},
{"of|outputfile=", "The output file which is generated.", v => outputFile = v},
{ "h|help", "Show this message and exit", v => shopHelp = true},
{ "s|skip", "Skip directory creation and asset-folder copy", v => copyAssets = false},
{ "sf|skipfile", "Skip output file copy", v => copyFile = true},
};
options.Parse(args);
if (shopHelp)
{
options.WriteOptionDescriptions(Console.Out);
if (Debugger.IsAttached)
Console.ReadLine();
Environment.Exit(0);
}
return new Core.Parameters(templateRoot, outputRoot, copyAssets, templateFile, outputFile, copyFile);
}
示例8: ShowHelp
static void ShowHelp(OptionSet p)
{
Console.WriteLine("Usage: ObjectList [options] path1 [path2..pathN]");
Console.WriteLine();
Console.WriteLine("Options:");
p.WriteOptionDescriptions(Console.Out);
}
示例9: show_help
public static void show_help(string message, OptionSet option_set)
{
//Console.Error.WriteLine(message);
the_logger.Info(message);
option_set.WriteOptionDescriptions(Console.Error);
Environment.Exit(-1);
}
示例10: ShowHelp
static void ShowHelp(OptionSet p)
{
Console.WriteLine("Usage: SpeechBox [OPTIONS]+ message");
Console.WriteLine();
Console.WriteLine("Options:");
p.WriteOptionDescriptions(Console.Out);
}
示例11: Check
/// <summary>
/// Method performing the check command
/// </summary>
/// <param name="argsList">
/// Command line like style
/// </param>
public static void Check(IEnumerable<string> argsList)
{
string outname = null;
bool help = false;
var op = new OptionSet() {
{"check", "Command name, consumes token", v => int.Parse("0")},
{"save|outname=", "Output of the tabulation filename", v => outname = v},
{"help|h", "Shows this help message", v => help = true}
};
List<string> checkList = op.Parse(argsList);
if (1 > checkList.Count || help) {
Console.WriteLine ("Usage --check [--options] res-basis res-list...");
op.WriteOptionDescriptions(Console.Out);
return;
}
var list = new List<ResultSummary> ();
var B = JsonConvert.DeserializeObject<ResultSummary> (File.ReadAllText (checkList [0]));
foreach(string arg in checkList) {
var R = JsonConvert.DeserializeObject<ResultSummary> (File.ReadAllText (arg));
R.Parametrize (B);
R.ResultName = arg;
R.QueryList = null;
list.Add (R);
// Console.WriteLine (JsonConvert.SerializeObject(R, Formatting.Indented));
}
var s = JsonConvert.SerializeObject (list, Formatting.Indented);
Console.WriteLine (s);
if (outname != null) {
File.WriteAllText(outname, s);
}
}
示例12: Main
static void Main(string[] args)
{
string folder = null, siteName = null, hostname = null;
var p = new OptionSet
{
{ "p|path=", v => folder = v },
{ "n|sitename=", v => siteName=v },
{ "h|hostname=", v => hostname = v}
};
p.Parse(args);
if (string.IsNullOrEmpty(folder) || string.IsNullOrEmpty(hostname) || string.IsNullOrEmpty(siteName))
{
p.WriteOptionDescriptions(Console.Out);
return;
}
try
{
HostFile.EnsureHostNameBoundToLocalhost(hostname);
ServerManager.CreateSiteWithHostName(new ServerManager.SiteWithHostName(
name: siteName,
host: hostname,
folder: folder
));
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
Environment.Exit(1);
}
}
示例13: ShowHelp
protected void ShowHelp(OptionSet options)
{
var cmdName = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
Debug.WriteLine("Usage: {0} [options]+", cmdName);
Debug.WriteLine("Options:");
options.WriteOptionDescriptions(Console.Out);
}
示例14: Main
static int Main(string[] args) {
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
bool verbose = false;
string inFilename = null;
string outFilename = null;
var p = new OptionSet {
{ "v", "Verbose", v => verbose = v != null },
{ "in=", "Input dll file", s => inFilename = s },
{ "out=", "Output JavaScript file. Will be overwritten if already exists", s => outFilename = s },
};
var r = p.Parse(args);
if (inFilename == null || outFilename == null || r.Any()) {
Console.WriteLine("Cil2JsCon");
Console.WriteLine("Convert .NET library to JavaScript");
Console.WriteLine();
Console.WriteLine("Options:");
p.WriteOptionDescriptions(Console.Out);
return 1;
}
var jsResult = Transcoder.ToJs(inFilename, verbose);
var typeMapString = jsResult.TypeMap.ToString();
try {
File.WriteAllText(outFilename, jsResult.Js, Encoding.UTF8);
File.WriteAllText(outFilename + ".typemap", typeMapString);
} catch (Exception e) {
Console.WriteLine("Error:");
Console.WriteLine(e);
}
return 0;
}
示例15: ShowHelp
static void ShowHelp (OptionSet os)
{
Console.WriteLine ("Usage: respack outputfile [file1[,name] .. [fileN]]");
Console.WriteLine ();
os.WriteOptionDescriptions (Console.Out);
Environment.Exit (0);
}