本文整理汇总了C#中CommandLineApplication.ShowRootCommandFullNameAndVersion方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLineApplication.ShowRootCommandFullNameAndVersion方法的具体用法?C# CommandLineApplication.ShowRootCommandFullNameAndVersion怎么用?C# CommandLineApplication.ShowRootCommandFullNameAndVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandLineApplication
的用法示例。
在下文中一共展示了CommandLineApplication.ShowRootCommandFullNameAndVersion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
private static void Run(CommandLineApplication cmd)
{
cmd.Description = "Set imports for project.json files";
var argRoot = cmd.Argument(
"[root]",
"directory",
multipleValues: true);
cmd.HelpOption("-?|-h|--help");
cmd.OnExecute(() =>
{
cmd.ShowRootCommandFullNameAndVersion();
foreach (var arg in argRoot.Values)
{
var dir = new DirectoryInfo(arg);
foreach (var file in dir.GetFiles("project.json", SearchOption.AllDirectories))
{
Process(file);
}
}
return 0;
});
}
示例2: Run
private static void Run(CommandLineApplication cmd)
{
cmd.Description = "Update a package version.";
var packageId = cmd.Option(
"-i|--id <id>",
"package id",
CommandOptionType.SingleValue);
var packageVersion = cmd.Option(
"-v|--version <version>",
"package version",
CommandOptionType.SingleValue);
var argRoot = cmd.Argument(
"[root]",
"directory",
multipleValues: true);
cmd.HelpOption("-?|-h|--help");
cmd.OnExecute(() =>
{
cmd.ShowRootCommandFullNameAndVersion();
if (string.IsNullOrEmpty(packageId.Value()))
{
throw new ArgumentException($"Missing value: {packageId.LongName}");
}
VersionRange version;
if (!VersionRange.TryParse(packageVersion.Value(), out version))
{
throw new ArgumentException($"Invalid value for: {packageVersion.LongName}");
}
foreach (var arg in argRoot.Values)
{
var dir = new DirectoryInfo(arg);
foreach (var file in dir.GetFiles("project.json", SearchOption.AllDirectories))
{
Process(file, packageId.Value(), version);
}
}
return 0;
});
}
示例3: Run
private static void Run(CommandLineApplication cmd)
{
cmd.Description = "Update a release label across pacakges.";
var find = cmd.Option(
"-f|--find <label>",
"release label. Ex: alpha-100",
CommandOptionType.SingleValue);
var replace = cmd.Option(
"-r|--replace <label>",
"release label. Ex: alpha-101",
CommandOptionType.SingleValue);
var argRoot = cmd.Argument(
"[root]",
"directory",
multipleValues: true);
cmd.HelpOption("-?|-h|--help");
cmd.OnExecute(() =>
{
cmd.ShowRootCommandFullNameAndVersion();
if (string.IsNullOrEmpty(find.Value()))
{
throw new ArgumentException($"Missing value: {find.LongName}");
}
if (string.IsNullOrEmpty(replace.Value()))
{
throw new ArgumentException($"Missing value: {replace.LongName}");
}
foreach (var arg in argRoot.Values)
{
var dir = new DirectoryInfo(arg);
foreach (var file in dir.GetFiles("project.json", SearchOption.AllDirectories))
{
Process(file, find.Value(), replace.Value());
}
}
return 0;
});
}
示例4: Run
private static void Run(CommandLineApplication cmd)
{
cmd.Description = "Copy runtime assemblies to a flat folder structure.";
var optionQuiet = cmd.Option("--verbosity", "Verbosity level.",
CommandOptionType.NoValue);
var optionPrerelease = cmd.Option("-p|--prerelease", "Include pre-release versions.",
CommandOptionType.NoValue);
var optionVersion = cmd.Option("-v|--version", "Package version.",
CommandOptionType.SingleValue);
var optionSource = cmd.Option("-s|--source", "Package source. This can be used multiple times.",
CommandOptionType.MultipleValue);
var optionOutput = cmd.Option("-o|--output", "Output directory.",
CommandOptionType.SingleValue);
var optionConfigFile = cmd.Option("-c|--config", "NuGet.Config file to read sources and settings from.",
CommandOptionType.SingleValue);
var optionFramework = cmd.Option("-f|--framework", "Target framework.",
CommandOptionType.SingleValue);
var optionRuntime = cmd.Option("-r|--runtime", "Runtime Id. This may be used multiple times.",
CommandOptionType.MultipleValue);
var optionPackageId = cmd.Option("-i|--id", "Package id.",
CommandOptionType.SingleValue);
cmd.HelpOption("-?|-h|--help");
var required = new List<CommandOption>()
{
optionPackageId,
optionOutput,
optionFramework,
};
cmd.OnExecute(() =>
{
cmd.ShowRootCommandFullNameAndVersion();
// Validate parameters
foreach (var requiredOption in required)
{
if (!requiredOption.HasValue())
{
throw new ArgumentException($"Missing required parameter --{requiredOption.LongName}.");
}
}
// Create project.json
// Restore
// Check restore result
// Copy runtime assemblies
return 0;
});
}