Вы можете использовать CommandLineApplication
из https://www.nuget.org/packages/Microsoft.Extensions.CommandLineUtils
, тогда вы можете настроить параметры командной строки и другие доступные параметры и явно использовать их позже.
Например:
var app = new CommandLineApplication()
{
Description = "CLI tool for copying messages from one queue to another",
Name = "copy-queue",
};
var sourceOption = _app.Option("--source|-s", $"The source queue name", CommandOptionType.SingleValue);
var destinationOption = _app.Option("--destination|-d", $"The destination queue name", CommandOptionType.SingleValue);
var profileOption = _app.Option("--profile|-p", $"AWS CLI profile (default: default)", CommandOptionType.SingleValue);
var regionOption = _app.Option("--region|-r", $"AWS region (default: us-east-1)", CommandOptionType.SingleValue);
var batchSizeOption = _app.Option("--batch-size|-b", $"Batch size (default: 10)", CommandOptionType.SingleValue);
_app.HelpOption("--help|-h|-?");
var name = Assembly.GetEntryAssembly().GetName();
_app.VersionOption("--version", name.Name + " " + name.Version);
_app.Invoke = () => ExecuteAsync().Result;
try
{
return _app.Execute(args);
}
catch (CommandParsingException cpe)
{
Console.WriteLine(cpe.Message);
return 1;
}