Redpoint.CommandLine 2024.1334.764

Prefix Reserved
There is a newer version of this package available.
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                
#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                

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 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2025.1002.636 80 1/2/2025
2025.1001.1435 76 1/2/2025
2025.1001.1397 75 1/1/2025
2025.1001.770 82 1/1/2025
2025.1001.570 87 1/1/2025
2025.1001.558 77 1/1/2025
2025.1001.421 87 1/1/2025
2025.1001.390 80 1/1/2025
2025.1001.234 91 1/1/2025
2025.1001.123 81 1/1/2025
2024.1360.354 71 12/25/2024
2024.1360.60 74 12/25/2024
2024.1360.32 76 12/25/2024
2024.1358.450 83 12/23/2024
2024.1358.359 75 12/23/2024
2024.1358.312 76 12/23/2024
2024.1358.244 76 12/23/2024
2024.1358.120 83 12/23/2024
2024.1348.253 79 12/13/2024
2024.1345.1379 77 12/10/2024
2024.1345.506 80 12/10/2024
2024.1345.379 74 12/10/2024
2024.1345.145 75 12/10/2024
2024.1345.72 80 12/10/2024
2024.1345.69 71 12/10/2024
2024.1345.15 78 12/10/2024
2024.1344.1436 79 12/10/2024
2024.1344.600 88 12/9/2024
2024.1344.411 76 12/9/2024
2024.1340.379 87 12/5/2024
2024.1340.15 86 12/5/2024
2024.1338.786 83 12/3/2024
2024.1338.722 92 12/3/2024
2024.1338.697 85 12/3/2024
2024.1338.639 87 12/3/2024
2024.1338.541 86 12/3/2024
2024.1338.318 76 12/3/2024
2024.1338.298 81 12/3/2024
2024.1338.98 89 12/3/2024
2024.1337.756 86 12/2/2024
2024.1337.634 85 12/2/2024
2024.1337.625 85 12/2/2024
2024.1337.621 88 12/2/2024
2024.1337.594 82 12/2/2024
2024.1337.136 68 12/2/2024
2024.1336.793 87 12/1/2024
2024.1336.773 86 12/1/2024
2024.1336.305 84 12/1/2024
2024.1336.12 91 12/1/2024
2024.1335.1421 85 11/30/2024
2024.1335.1384 83 11/30/2024
2024.1334.1308 81 11/29/2024
2024.1334.764 85 11/29/2024
2024.1334.722 86 11/29/2024
2024.1330.185 84 11/25/2024
2024.1328.505 83 11/23/2024
2024.1328.470 86 11/23/2024
2024.1328.452 85 11/23/2024
2024.1323.910 85 11/18/2024
2024.1323.653 78 11/18/2024
2024.1323.185 87 11/18/2024
2024.1323.49 76 11/18/2024
2024.1322.714 88 11/17/2024
2024.1320.653 84 11/15/2024
2024.1320.619 74 11/15/2024
2024.1320.601 86 11/15/2024
2024.1320.159 82 11/15/2024
2024.1320.98 79 11/15/2024
2024.1320.2 80 11/15/2024
2024.1319.1431 81 11/15/2024
2024.1319.1335 78 11/14/2024
2024.1317.631 87 11/12/2024
2024.1316.330 102 11/11/2024
2024.1311.540 93 11/6/2024
2024.1306.225 89 11/1/2024
2024.1306.199 89 11/1/2024
2024.1306.171 85 11/1/2024
2024.1306.117 83 11/1/2024
2024.1305.506 81 10/31/2024
2024.1305.502 91 10/31/2024
2024.1305.465 86 10/31/2024
2024.1305.442 80 10/31/2024
2024.1305.399 88 10/31/2024
2024.1299.1070 80 10/25/2024
2024.1289.621 89 10/15/2024
2024.1289.338 89 10/15/2024
2024.1277.836 94 10/5/2024
2024.1277.711 88 10/3/2024
2024.1277.695 89 10/3/2024
2024.1270.409 97 9/26/2024
2024.1269.621 113 9/25/2024
2024.1269.619 99 9/25/2024
2024.1269.605 101 9/25/2024
2024.1242.282 110 8/29/2024
2024.1242.261 91 8/29/2024
2024.1242.233 111 8/29/2024
2024.1238.829 110 8/25/2024
2024.1238.327 127 8/25/2024
2024.1225.297 122 8/12/2024
2024.1205.140 78 7/23/2024
2024.1204.110 113 7/22/2024
2024.1204.62 79 7/22/2024
2024.1190.491 110 7/8/2024
2024.1177.305 115 6/25/2024
2024.1168.700 95 6/16/2024
2024.1168.649 108 6/16/2024
2024.1168.535 97 6/16/2024
2024.1167.643 102 6/15/2024
2024.1166.989 115 6/14/2024
2024.1166.818 87 6/14/2024
2024.1166.535 92 6/14/2024
2024.1166.422 108 6/14/2024
2024.1166.362 94 6/14/2024
2024.1166.360 94 6/14/2024
2024.1165.1212 99 6/13/2024
2024.1165.1160 87 6/13/2024
2024.1165.1019 99 6/13/2024
2024.1165.978 108 6/13/2024
2024.1165.920 103 6/13/2024
2024.1165.908 88 6/13/2024
2024.1165.873 89 6/13/2024
2024.1165.830 112 6/13/2024
2024.1165.806 113 6/13/2024
2024.1165.794 90 6/13/2024
2024.1165.792 104 6/13/2024
2024.1165.761 103 6/13/2024
2024.1165.743 104 6/13/2024
2024.1165.735 88 6/13/2024
2024.1165.713 112 6/13/2024
2024.1165.640 93 6/13/2024
2024.1165.574 106 6/13/2024
2024.1165.466 104 6/13/2024
2024.1165.417 118 6/13/2024
2024.1165.392 106 6/13/2024
2024.1164.341 82 6/12/2024
2024.1155.941 115 6/3/2024
2024.1140.783 115 5/19/2024
2024.1140.692 111 5/19/2024
2024.1140.673 94 5/19/2024
2024.1129.506 118 5/8/2024
2024.1128.831 134 5/7/2024
2024.1124.465 88 5/3/2024
2024.1123.1162 81 5/2/2024
2024.1123.1117 66 5/2/2024
2024.1123.1050 73 5/2/2024
2024.1122.352 114 5/1/2024
2024.1122.233 101 5/1/2024
2024.1115.1101 124 4/24/2024
2024.1115.1048 98 4/24/2024
2024.1115.932 104 4/24/2024
2024.1115.858 94 4/24/2024
2024.1115.665 105 4/24/2024
2024.1115.648 124 4/24/2024
2024.1115.591 96 4/24/2024
2024.1101.390 103 4/10/2024
2024.1100.741 120 4/9/2024
2024.1099.526 99 4/8/2024
2024.1099.466 104 4/8/2024
2024.1098.573 123 4/7/2024
2024.1095.977 103 4/4/2024
2024.1095.847 98 4/4/2024
2024.1095.604 105 4/4/2024
2024.1095.485 119 4/4/2024
2024.1094.930 100 4/3/2024
2024.1094.910 116 4/3/2024
2024.1094.387 114 4/3/2024
2024.1094.313 116 4/3/2024
2024.1093.520 113 4/2/2024
2024.1092.240 107 4/1/2024
2024.1089.1425 119 3/29/2024
2024.1089.983 105 3/29/2024
2024.1089.942 98 3/29/2024
2024.1089.2 101 3/29/2024
2024.1088.1343 126 3/28/2024
2024.1088.1139 118 3/28/2024
2024.1088.875 113 3/28/2024
2024.1088.700 133 3/28/2024
2024.1088.603 122 3/28/2024
2024.1088.590 93 3/28/2024
2024.1088.575 124 3/28/2024
2024.1088.561 126 3/28/2024
2024.1088.506 103 3/28/2024
2024.1088.18 104 3/28/2024
2024.1087.1181 135 3/27/2024
2024.1087.1173 103 3/27/2024
2024.1087.1143 123 3/27/2024
2024.1087.1108 109 3/27/2024
2024.1087.950 140 3/27/2024
2024.1087.939 114 3/27/2024
2024.1087.252 116 3/27/2024
2024.1070.736 136 3/10/2024
2024.1049.1437 143 2/19/2024
2024.1036.571 134 2/5/2024
2024.1036.508 96 2/5/2024
2024.1032.1204 109 2/1/2024
2024.1032.1133 98 2/1/2024
2024.1032.1122 113 2/1/2024
2024.1032.1071 94 2/1/2024
2024.1032.940 115 2/1/2024
2024.1031.912 112 1/31/2024
2024.1031.893 94 1/31/2024
2024.1031.851 113 1/31/2024
2024.1031.829 108 1/31/2024
2024.1031.386 123 1/31/2024
2024.1031.318 118 1/31/2024
2024.1017.460 126 1/17/2024
2024.1017.420 112 1/17/2024
2024.1017.163 114 1/17/2024
2024.1016.414 317 1/16/2024
2024.1012.167 133 1/12/2024
2024.1011.406 116 1/11/2024
2024.1010.315 123 1/10/2024
2023.1358.326 154 12/24/2023
2023.1351.473 142 12/17/2023
2023.1351.445 113 12/17/2023
2023.1351.432 126 12/17/2023
2023.1350.478 115 12/16/2023
2023.1344.600 123 12/10/2023
2023.1344.529 133 12/10/2023
2023.1339.582 161 12/5/2023
2023.1338.1072 133 12/4/2023
2023.1336.844 136 12/2/2023
2023.1335.378 142 12/1/2023
2023.1335.236 139 12/1/2023
2023.1335.203 135 12/1/2023
2023.1334.814 129 11/30/2023
2023.1332.652 125 11/28/2023
2023.1332.622 138 11/28/2023
2023.1332.524 155 11/28/2023
2023.1331.1073 116 11/27/2023
2023.1331.423 125 11/27/2023
2023.1328.513 136 11/24/2023
2023.1327.985 144 11/23/2023
2023.1325.593 136 11/21/2023
2023.1325.551 139 11/21/2023
2023.1325.529 129 11/21/2023