本文整理汇总了C#中CommandLineParser.PrintHelp方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineParser.PrintHelp方法的具体用法?C# CommandLineParser.PrintHelp怎么用?C# CommandLineParser.PrintHelp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineParser
的用法示例。
在下文中一共展示了CommandLineParser.PrintHelp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run(string[] args, TextWriter log)
{
log.WriteLine("{0} {1}", typeof(Program).Assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false).Cast<AssemblyProductAttribute>().Single().Product, typeof(Program).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false).Cast<AssemblyInformationalVersionAttribute>().Single().InformationalVersion);
log.WriteLine(typeof(Program).Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false).Cast<AssemblyDescriptionAttribute>().Single().Description);
log.WriteLine(typeof(Program).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false).Cast<AssemblyCopyrightAttribute>().Single().Copyright);
var commandLineParser = new CommandLineParser<Options>();
if(args.Length == 0)
{
log.WriteLine("Command line parameters:");
commandLineParser.PrintHelp(log);
return;
}
Options opts = commandLineParser.Parse(args);
var db = new MssqlDatabase(opts.ConnStr, opts.Timeout);
var scriptBuilder = new ScriptBuilder(db, log);
var migrationFilter = new MigrationFilter(new MigrationRepository(opts.MigrationsDir, opts.TextEncoding, db), db);
string script;
if(opts.Count >= 0)
{
log.WriteLine("Building Up script");
script = scriptBuilder.BuildUp(migrationFilter.GetPendingMigrations(), opts.Count);
}
else
{
log.WriteLine("Building Down script");
script = scriptBuilder.BuildDown(migrationFilter.GetApplyedMigrations(), -opts.Count);
}
if(string.IsNullOrWhiteSpace(opts.OutputFile))
{
log.WriteLine("Executing script to {0}", opts.ConnStr);
db.Execute(script);
}
else
{
log.WriteLine("Saving script to {0}", opts.OutputFile);
File.WriteAllText(opts.OutputFile, script, opts.TextEncoding);
}
}