Redpoint.CommandLine 2024.1115.1101

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. 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.1115.1101
NuGet\Install-Package Redpoint.CommandLine -Version 2024.1115.1101
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.1115.1101" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Redpoint.CommandLine --version 2024.1115.1101
#r "nuget: Redpoint.CommandLine, 2024.1115.1101"
#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.1115.1101

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

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 (1)

Showing the top 1 NuGet packages that depend on Redpoint.CommandLine:

Package Downloads
Redpoint.CloudFramework.CLI The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

The command line tool for Redpoint.CloudFramework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.1124.465 3 5/3/2024
2024.1123.1162 2 5/2/2024
2024.1123.1117 0 5/2/2024
2024.1123.1050 0 5/2/2024
2024.1122.352 66 5/1/2024
2024.1122.233 69 5/1/2024
2024.1115.1101 81 4/24/2024
2024.1115.1048 59 4/24/2024
2024.1115.932 82 4/24/2024
2024.1115.858 68 4/24/2024
2024.1115.665 77 4/24/2024
2024.1115.648 73 4/24/2024
2024.1115.591 67 4/24/2024
2024.1101.390 74 4/10/2024
2024.1100.741 77 4/9/2024
2024.1099.526 77 4/8/2024
2024.1099.466 72 4/8/2024
2024.1098.573 81 4/7/2024
2024.1095.977 80 4/4/2024
2024.1095.847 76 4/4/2024
2024.1095.604 79 4/4/2024
2024.1095.485 81 4/4/2024
2024.1094.930 77 4/3/2024
2024.1094.910 82 4/3/2024
2024.1094.387 80 4/3/2024
2024.1094.313 83 4/3/2024
2024.1093.520 87 4/2/2024
2024.1092.240 85 4/1/2024
2024.1089.1425 78 3/29/2024
2024.1089.983 77 3/29/2024
2024.1089.942 70 3/29/2024
2024.1089.2 80 3/29/2024
2024.1088.1343 82 3/28/2024
2024.1088.1139 80 3/28/2024
2024.1088.875 80 3/28/2024
2024.1088.700 83 3/28/2024
2024.1088.603 75 3/28/2024
2024.1088.590 72 3/28/2024
2024.1088.575 84 3/28/2024
2024.1088.561 80 3/28/2024
2024.1088.506 79 3/28/2024
2024.1088.18 83 3/28/2024
2024.1087.1181 86 3/27/2024
2024.1087.1173 74 3/27/2024
2024.1087.1143 84 3/27/2024
2024.1087.1108 80 3/27/2024
2024.1087.950 87 3/27/2024
2024.1087.939 86 3/27/2024
2024.1087.252 75 3/27/2024
2024.1070.736 87 3/10/2024
2024.1049.1437 90 2/19/2024
2024.1036.571 87 2/5/2024
2024.1036.508 72 2/5/2024
2024.1032.1204 79 2/1/2024
2024.1032.1133 70 2/1/2024
2024.1032.1122 73 2/1/2024
2024.1032.1071 70 2/1/2024
2024.1032.940 75 2/1/2024
2024.1031.912 74 1/31/2024
2024.1031.893 73 1/31/2024
2024.1031.851 70 1/31/2024
2024.1031.829 70 1/31/2024
2024.1031.386 74 1/31/2024
2024.1031.318 74 1/31/2024
2024.1017.460 100 1/17/2024
2024.1017.420 72 1/17/2024
2024.1017.163 81 1/17/2024
2024.1016.414 162 1/16/2024
2024.1012.167 83 1/12/2024
2024.1011.406 89 1/11/2024
2024.1010.315 88 1/10/2024
2023.1358.326 116 12/24/2023
2023.1351.473 102 12/17/2023
2023.1351.445 79 12/17/2023
2023.1351.432 86 12/17/2023
2023.1350.478 88 12/16/2023
2023.1344.600 94 12/10/2023
2023.1344.529 85 12/10/2023
2023.1339.582 108 12/5/2023
2023.1338.1072 89 12/4/2023
2023.1336.844 103 12/2/2023
2023.1335.378 97 12/1/2023
2023.1335.236 104 12/1/2023
2023.1335.203 91 12/1/2023
2023.1334.814 108 11/30/2023
2023.1332.652 96 11/28/2023
2023.1332.622 90 11/28/2023
2023.1332.524 107 11/28/2023
2023.1331.1073 75 11/27/2023
2023.1331.423 98 11/27/2023
2023.1328.513 98 11/24/2023
2023.1327.985 99 11/23/2023
2023.1325.593 87 11/21/2023
2023.1325.551 109 11/21/2023
2023.1325.529 103 11/21/2023