Redpoint.CommandLine 2024.1165.417

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.1165.417                
NuGet\Install-Package Redpoint.CommandLine -Version 2024.1165.417                
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.1165.417" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Redpoint.CommandLine --version 2024.1165.417                
#r "nuget: Redpoint.CommandLine, 2024.1165.417"                
#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.1165.417

// Install Redpoint.CommandLine as a Cake Tool
#tool nuget:?package=Redpoint.CommandLine&version=2024.1165.417                

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. 
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
2024.1330.185 44 11/25/2024
2024.1328.505 51 11/23/2024
2024.1328.470 47 11/23/2024
2024.1328.452 49 11/23/2024
2024.1323.910 68 11/18/2024
2024.1323.653 62 11/18/2024
2024.1323.185 74 11/18/2024
2024.1323.49 61 11/18/2024
2024.1322.714 73 11/17/2024
2024.1320.653 69 11/15/2024
2024.1320.619 61 11/15/2024
2024.1320.601 72 11/15/2024
2024.1320.159 65 11/15/2024
2024.1320.98 64 11/15/2024
2024.1320.2 62 11/15/2024
2024.1319.1431 62 11/15/2024
2024.1319.1335 63 11/14/2024
2024.1317.631 72 11/12/2024
2024.1316.330 86 11/11/2024
2024.1311.540 79 11/6/2024
2024.1306.225 74 11/1/2024
2024.1306.199 73 11/1/2024
2024.1306.171 70 11/1/2024
2024.1306.117 69 11/1/2024
2024.1305.506 68 10/31/2024
2024.1305.502 79 10/31/2024
2024.1305.465 73 10/31/2024
2024.1305.442 67 10/31/2024
2024.1305.399 77 10/31/2024
2024.1299.1070 69 10/25/2024
2024.1289.621 79 10/15/2024
2024.1289.338 75 10/15/2024
2024.1277.836 85 10/5/2024
2024.1277.711 80 10/3/2024
2024.1277.695 79 10/3/2024
2024.1270.409 89 9/26/2024
2024.1269.621 105 9/25/2024
2024.1269.619 89 9/25/2024
2024.1269.605 91 9/25/2024
2024.1242.282 100 8/29/2024
2024.1242.261 81 8/29/2024
2024.1242.233 103 8/29/2024
2024.1238.829 100 8/25/2024
2024.1238.327 117 8/25/2024
2024.1225.297 114 8/12/2024
2024.1205.140 68 7/23/2024
2024.1204.110 101 7/22/2024
2024.1204.62 69 7/22/2024
2024.1190.491 102 7/8/2024
2024.1177.305 103 6/25/2024
2024.1168.700 85 6/16/2024
2024.1168.649 100 6/16/2024
2024.1168.535 87 6/16/2024
2024.1167.643 94 6/15/2024
2024.1166.989 103 6/14/2024
2024.1166.818 79 6/14/2024
2024.1166.535 82 6/14/2024
2024.1166.422 98 6/14/2024
2024.1166.362 84 6/14/2024
2024.1166.360 84 6/14/2024
2024.1165.1212 89 6/13/2024
2024.1165.1160 78 6/13/2024
2024.1165.1019 91 6/13/2024
2024.1165.978 98 6/13/2024
2024.1165.920 92 6/13/2024
2024.1165.908 80 6/13/2024
2024.1165.873 79 6/13/2024
2024.1165.830 102 6/13/2024
2024.1165.806 95 6/13/2024
2024.1165.794 78 6/13/2024
2024.1165.792 94 6/13/2024
2024.1165.761 91 6/13/2024
2024.1165.743 92 6/13/2024
2024.1165.735 78 6/13/2024
2024.1165.713 102 6/13/2024
2024.1165.640 81 6/13/2024
2024.1165.574 98 6/13/2024
2024.1165.466 94 6/13/2024
2024.1165.417 102 6/13/2024
2024.1165.392 98 6/13/2024
2024.1164.341 70 6/12/2024
2024.1155.941 107 6/3/2024
2024.1140.783 107 5/19/2024
2024.1140.692 103 5/19/2024
2024.1140.673 84 5/19/2024
2024.1129.506 108 5/8/2024
2024.1128.831 122 5/7/2024
2024.1124.465 80 5/3/2024
2024.1123.1162 75 5/2/2024
2024.1123.1117 58 5/2/2024
2024.1123.1050 67 5/2/2024
2024.1122.352 106 5/1/2024
2024.1122.233 93 5/1/2024
2024.1115.1101 116 4/24/2024
2024.1115.1048 92 4/24/2024
2024.1115.932 98 4/24/2024
2024.1115.858 84 4/24/2024
2024.1115.665 97 4/24/2024
2024.1115.648 116 4/24/2024
2024.1115.591 86 4/24/2024
2024.1101.390 95 4/10/2024
2024.1100.741 110 4/9/2024
2024.1099.526 90 4/8/2024
2024.1099.466 96 4/8/2024
2024.1098.573 113 4/7/2024
2024.1095.977 93 4/4/2024
2024.1095.847 90 4/4/2024
2024.1095.604 97 4/4/2024
2024.1095.485 111 4/4/2024
2024.1094.930 92 4/3/2024
2024.1094.910 109 4/3/2024
2024.1094.387 108 4/3/2024
2024.1094.313 108 4/3/2024
2024.1093.520 107 4/2/2024
2024.1092.240 101 4/1/2024
2024.1089.1425 111 3/29/2024
2024.1089.983 97 3/29/2024
2024.1089.942 90 3/29/2024
2024.1089.2 95 3/29/2024
2024.1088.1343 120 3/28/2024
2024.1088.1139 112 3/28/2024
2024.1088.875 107 3/28/2024
2024.1088.700 127 3/28/2024
2024.1088.603 113 3/28/2024
2024.1088.590 87 3/28/2024
2024.1088.575 116 3/28/2024
2024.1088.561 118 3/28/2024
2024.1088.506 97 3/28/2024
2024.1088.18 96 3/28/2024
2024.1087.1181 129 3/27/2024
2024.1087.1173 97 3/27/2024
2024.1087.1143 117 3/27/2024
2024.1087.1108 103 3/27/2024
2024.1087.950 134 3/27/2024
2024.1087.939 108 3/27/2024
2024.1087.252 110 3/27/2024
2024.1070.736 130 3/10/2024
2024.1049.1437 137 2/19/2024
2024.1036.571 128 2/5/2024
2024.1036.508 90 2/5/2024
2024.1032.1204 103 2/1/2024
2024.1032.1133 92 2/1/2024
2024.1032.1122 107 2/1/2024
2024.1032.1071 88 2/1/2024
2024.1032.940 109 2/1/2024
2024.1031.912 106 1/31/2024
2024.1031.893 88 1/31/2024
2024.1031.851 107 1/31/2024
2024.1031.829 102 1/31/2024
2024.1031.386 117 1/31/2024
2024.1031.318 112 1/31/2024
2024.1017.460 120 1/17/2024
2024.1017.420 106 1/17/2024
2024.1017.163 108 1/17/2024
2024.1016.414 296 1/16/2024
2024.1012.167 127 1/12/2024
2024.1011.406 110 1/11/2024
2024.1010.315 117 1/10/2024
2023.1358.326 148 12/24/2023
2023.1351.473 136 12/17/2023
2023.1351.445 107 12/17/2023
2023.1351.432 118 12/17/2023
2023.1350.478 109 12/16/2023
2023.1344.600 117 12/10/2023
2023.1344.529 125 12/10/2023
2023.1339.582 155 12/5/2023
2023.1338.1072 127 12/4/2023
2023.1336.844 128 12/2/2023
2023.1335.378 136 12/1/2023
2023.1335.236 133 12/1/2023
2023.1335.203 129 12/1/2023
2023.1334.814 123 11/30/2023
2023.1332.652 119 11/28/2023
2023.1332.622 132 11/28/2023
2023.1332.524 149 11/28/2023
2023.1331.1073 104 11/27/2023
2023.1331.423 119 11/27/2023
2023.1328.513 130 11/24/2023
2023.1327.985 138 11/23/2023
2023.1325.593 130 11/21/2023
2023.1325.551 133 11/21/2023
2023.1325.529 123 11/21/2023