Redpoint.CommandLine
2024.1334.764
Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Redpoint.CommandLine --version 2024.1334.764
NuGet\Install-Package Redpoint.CommandLine -Version 2024.1334.764
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Redpoint.CommandLine" Version="2024.1334.764" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Redpoint.CommandLine --version 2024.1334.764
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Redpoint.CommandLine, 2024.1334.764"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Redpoint.CommandLine as a Cake Addin #addin nuget:?package=Redpoint.CommandLine&version=2024.1334.764 // Install Redpoint.CommandLine as a Cake Tool #tool nuget:?package=Redpoint.CommandLine&version=2024.1334.764
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Redpoint.CommandLine
This library provides APIs for building dependency injected console applications, with both commands and option declarations being dependency injected.
To use this library, first define your command:
internal class SomeAction
{
public class Options
{
public Option<string> SomeOpt = new Option<string>("--opt", "My option description.");
// Add more fields or properties that use Option<> or Argument<> and they'll be automatically
// registered to the command line parser.
}
public static Command CreateCommand(ICommandBuilder builder)
{
return new Command("some-action", "The description of your some-action command.");
}
public class CommandInstance : ICommandInstance
{
private readonly ILogger<CommandInstance> _logger;
private readonly Options _options;
public CommandInstance(
ILogger<CommandInstance> logger,
Options options)
{
_logger = logger;
_options = options;
}
public Task<int> ExecuteAsync(ICommandInvocationContext context)
{
// Example on how to access an option's value.
var value = context.ParseResult.GetValueForOption(_options.SomeOpt);
// ... implement your command here ...
_logger.LogInformation("Hello world!");
// Return the exit code for the application.
return Task.FromResult(0);
}
}
}
To register and execute commands, in your Program.Main:
// Use the command line builder APIs to build the root command.
var rootCommand = CommandLineBuilder.NewBuilder()
.AddGlobalRuntimeServices((builder, services) =>
{
// Register global runtime services here, such as services.AddLogging(...)
})
.SetGlobalExecutionHandler(async (sp, executeCommand) =>
{
// Can be used to wrap execution of all commands, such as capturing
// exceptions and logging them:
var logger = sp.GetRequiredService<ILogger<Program>>();
try
{
return await executeCommand().ConfigureAwait(true);
}
catch (Exception ex)
{
logger.LogError(ex, $"Uncaught exception during command execution: {ex}");
return 1;
}
})
// Add each of your commands like this:
.AddCommand<SomeAction.CommandInstance, SomeAction.Options>(SomeAction.CreateCommand)
// Then build the root command to use below.
.Build("My console application description.");
// Parse and execute the command.
var exitCode = await rootCommand.InvokeAsync(args).ConfigureAwait(false);
await Console.Out.FlushAsync().ConfigureAwait(false);
await Console.Error.FlushAsync().ConfigureAwait(false);
Environment.Exit(exitCode);
throw new BadImageFormatException();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Redpoint.Concurrency (>= 2024.1334.764)
- Redpoint.ThirdParty.System.CommandLine (>= 2024.1334.764)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2024.1336.793 | 0 | 12/1/2024 |
2024.1336.773 | 0 | 12/1/2024 |
2024.1336.305 | 25 | 12/1/2024 |
2024.1336.12 | 33 | 12/1/2024 |
2024.1335.1421 | 30 | 11/30/2024 |
2024.1335.1384 | 31 | 11/30/2024 |
2024.1334.1308 | 39 | 11/29/2024 |
2024.1334.764 | 38 | 11/29/2024 |
2024.1334.722 | 43 | 11/29/2024 |
2024.1330.185 | 69 | 11/25/2024 |
2024.1328.505 | 74 | 11/23/2024 |
2024.1328.470 | 75 | 11/23/2024 |
2024.1328.452 | 72 | 11/23/2024 |
2024.1323.910 | 72 | 11/18/2024 |
2024.1323.653 | 66 | 11/18/2024 |
2024.1323.185 | 78 | 11/18/2024 |
2024.1323.49 | 65 | 11/18/2024 |
2024.1322.714 | 77 | 11/17/2024 |
2024.1320.653 | 73 | 11/15/2024 |
2024.1320.619 | 65 | 11/15/2024 |
2024.1320.601 | 76 | 11/15/2024 |
2024.1320.159 | 69 | 11/15/2024 |
2024.1320.98 | 68 | 11/15/2024 |
2024.1320.2 | 66 | 11/15/2024 |
2024.1319.1431 | 66 | 11/15/2024 |
2024.1319.1335 | 67 | 11/14/2024 |
2024.1317.631 | 76 | 11/12/2024 |
2024.1316.330 | 90 | 11/11/2024 |
2024.1311.540 | 83 | 11/6/2024 |
2024.1306.225 | 78 | 11/1/2024 |
2024.1306.199 | 77 | 11/1/2024 |
2024.1306.171 | 74 | 11/1/2024 |
2024.1306.117 | 73 | 11/1/2024 |
2024.1305.506 | 70 | 10/31/2024 |
2024.1305.502 | 81 | 10/31/2024 |
2024.1305.465 | 75 | 10/31/2024 |
2024.1305.442 | 69 | 10/31/2024 |
2024.1305.399 | 79 | 10/31/2024 |
2024.1299.1070 | 71 | 10/25/2024 |
2024.1289.621 | 81 | 10/15/2024 |
2024.1289.338 | 77 | 10/15/2024 |
2024.1277.836 | 87 | 10/5/2024 |
2024.1277.711 | 82 | 10/3/2024 |
2024.1277.695 | 81 | 10/3/2024 |
2024.1270.409 | 91 | 9/26/2024 |
2024.1269.621 | 107 | 9/25/2024 |
2024.1269.619 | 91 | 9/25/2024 |
2024.1269.605 | 93 | 9/25/2024 |
2024.1242.282 | 102 | 8/29/2024 |
2024.1242.261 | 83 | 8/29/2024 |
2024.1242.233 | 105 | 8/29/2024 |
2024.1238.829 | 102 | 8/25/2024 |
2024.1238.327 | 119 | 8/25/2024 |
2024.1225.297 | 116 | 8/12/2024 |
2024.1205.140 | 70 | 7/23/2024 |
2024.1204.110 | 103 | 7/22/2024 |
2024.1204.62 | 71 | 7/22/2024 |
2024.1190.491 | 104 | 7/8/2024 |
2024.1177.305 | 105 | 6/25/2024 |
2024.1168.700 | 87 | 6/16/2024 |
2024.1168.649 | 102 | 6/16/2024 |
2024.1168.535 | 89 | 6/16/2024 |
2024.1167.643 | 96 | 6/15/2024 |
2024.1166.989 | 105 | 6/14/2024 |
2024.1166.818 | 81 | 6/14/2024 |
2024.1166.535 | 84 | 6/14/2024 |
2024.1166.422 | 100 | 6/14/2024 |
2024.1166.362 | 86 | 6/14/2024 |
2024.1166.360 | 86 | 6/14/2024 |
2024.1165.1212 | 91 | 6/13/2024 |
2024.1165.1160 | 80 | 6/13/2024 |
2024.1165.1019 | 93 | 6/13/2024 |
2024.1165.978 | 100 | 6/13/2024 |
2024.1165.920 | 94 | 6/13/2024 |
2024.1165.908 | 82 | 6/13/2024 |
2024.1165.873 | 81 | 6/13/2024 |
2024.1165.830 | 104 | 6/13/2024 |
2024.1165.806 | 97 | 6/13/2024 |
2024.1165.794 | 80 | 6/13/2024 |
2024.1165.792 | 96 | 6/13/2024 |
2024.1165.761 | 93 | 6/13/2024 |
2024.1165.743 | 94 | 6/13/2024 |
2024.1165.735 | 80 | 6/13/2024 |
2024.1165.713 | 104 | 6/13/2024 |
2024.1165.640 | 83 | 6/13/2024 |
2024.1165.574 | 100 | 6/13/2024 |
2024.1165.466 | 96 | 6/13/2024 |
2024.1165.417 | 104 | 6/13/2024 |
2024.1165.392 | 100 | 6/13/2024 |
2024.1164.341 | 72 | 6/12/2024 |
2024.1155.941 | 109 | 6/3/2024 |
2024.1140.783 | 109 | 5/19/2024 |
2024.1140.692 | 105 | 5/19/2024 |
2024.1140.673 | 86 | 5/19/2024 |
2024.1129.506 | 110 | 5/8/2024 |
2024.1128.831 | 124 | 5/7/2024 |
2024.1124.465 | 82 | 5/3/2024 |
2024.1123.1162 | 77 | 5/2/2024 |
2024.1123.1117 | 60 | 5/2/2024 |
2024.1123.1050 | 69 | 5/2/2024 |
2024.1122.352 | 108 | 5/1/2024 |
2024.1122.233 | 95 | 5/1/2024 |
2024.1115.1101 | 118 | 4/24/2024 |
2024.1115.1048 | 94 | 4/24/2024 |
2024.1115.932 | 100 | 4/24/2024 |
2024.1115.858 | 86 | 4/24/2024 |
2024.1115.665 | 99 | 4/24/2024 |
2024.1115.648 | 118 | 4/24/2024 |
2024.1115.591 | 88 | 4/24/2024 |
2024.1101.390 | 97 | 4/10/2024 |
2024.1100.741 | 112 | 4/9/2024 |
2024.1099.526 | 92 | 4/8/2024 |
2024.1099.466 | 98 | 4/8/2024 |
2024.1098.573 | 115 | 4/7/2024 |
2024.1095.977 | 95 | 4/4/2024 |
2024.1095.847 | 92 | 4/4/2024 |
2024.1095.604 | 99 | 4/4/2024 |
2024.1095.485 | 113 | 4/4/2024 |
2024.1094.930 | 94 | 4/3/2024 |
2024.1094.910 | 111 | 4/3/2024 |
2024.1094.387 | 110 | 4/3/2024 |
2024.1094.313 | 110 | 4/3/2024 |
2024.1093.520 | 109 | 4/2/2024 |
2024.1092.240 | 103 | 4/1/2024 |
2024.1089.1425 | 113 | 3/29/2024 |
2024.1089.983 | 99 | 3/29/2024 |
2024.1089.942 | 92 | 3/29/2024 |
2024.1089.2 | 97 | 3/29/2024 |
2024.1088.1343 | 122 | 3/28/2024 |
2024.1088.1139 | 114 | 3/28/2024 |
2024.1088.875 | 109 | 3/28/2024 |
2024.1088.700 | 129 | 3/28/2024 |
2024.1088.603 | 115 | 3/28/2024 |
2024.1088.590 | 89 | 3/28/2024 |
2024.1088.575 | 118 | 3/28/2024 |
2024.1088.561 | 120 | 3/28/2024 |
2024.1088.506 | 99 | 3/28/2024 |
2024.1088.18 | 98 | 3/28/2024 |
2024.1087.1181 | 131 | 3/27/2024 |
2024.1087.1173 | 99 | 3/27/2024 |
2024.1087.1143 | 119 | 3/27/2024 |
2024.1087.1108 | 105 | 3/27/2024 |
2024.1087.950 | 136 | 3/27/2024 |
2024.1087.939 | 110 | 3/27/2024 |
2024.1087.252 | 112 | 3/27/2024 |
2024.1070.736 | 132 | 3/10/2024 |
2024.1049.1437 | 139 | 2/19/2024 |
2024.1036.571 | 130 | 2/5/2024 |
2024.1036.508 | 92 | 2/5/2024 |
2024.1032.1204 | 105 | 2/1/2024 |
2024.1032.1133 | 94 | 2/1/2024 |
2024.1032.1122 | 109 | 2/1/2024 |
2024.1032.1071 | 90 | 2/1/2024 |
2024.1032.940 | 111 | 2/1/2024 |
2024.1031.912 | 108 | 1/31/2024 |
2024.1031.893 | 90 | 1/31/2024 |
2024.1031.851 | 109 | 1/31/2024 |
2024.1031.829 | 104 | 1/31/2024 |
2024.1031.386 | 119 | 1/31/2024 |
2024.1031.318 | 114 | 1/31/2024 |
2024.1017.460 | 122 | 1/17/2024 |
2024.1017.420 | 108 | 1/17/2024 |
2024.1017.163 | 110 | 1/17/2024 |
2024.1016.414 | 298 | 1/16/2024 |
2024.1012.167 | 129 | 1/12/2024 |
2024.1011.406 | 112 | 1/11/2024 |
2024.1010.315 | 119 | 1/10/2024 |
2023.1358.326 | 150 | 12/24/2023 |
2023.1351.473 | 138 | 12/17/2023 |
2023.1351.445 | 109 | 12/17/2023 |
2023.1351.432 | 120 | 12/17/2023 |
2023.1350.478 | 111 | 12/16/2023 |
2023.1344.600 | 119 | 12/10/2023 |
2023.1344.529 | 127 | 12/10/2023 |
2023.1339.582 | 157 | 12/5/2023 |
2023.1338.1072 | 129 | 12/4/2023 |
2023.1336.844 | 132 | 12/2/2023 |
2023.1335.378 | 138 | 12/1/2023 |
2023.1335.236 | 135 | 12/1/2023 |
2023.1335.203 | 131 | 12/1/2023 |
2023.1334.814 | 125 | 11/30/2023 |
2023.1332.652 | 121 | 11/28/2023 |
2023.1332.622 | 134 | 11/28/2023 |
2023.1332.524 | 151 | 11/28/2023 |
2023.1331.1073 | 106 | 11/27/2023 |
2023.1331.423 | 121 | 11/27/2023 |
2023.1328.513 | 132 | 11/24/2023 |
2023.1327.985 | 140 | 11/23/2023 |
2023.1325.593 | 132 | 11/21/2023 |
2023.1325.551 | 135 | 11/21/2023 |
2023.1325.529 | 125 | 11/21/2023 |