Jiro.Commands 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package Jiro.Commands --version 1.0.6
                    
NuGet\Install-Package Jiro.Commands -Version 1.0.6
                    
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="Jiro.Commands" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jiro.Commands" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Jiro.Commands" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jiro.Commands --version 1.0.6
                    
#r "nuget: Jiro.Commands, 1.0.6"
                    
#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.
#:package Jiro.Commands@1.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jiro.Commands&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Jiro.Commands&version=1.0.6
                    
Install as a Cake Tool

Jiro.Commands

Command base and plugin manager for Jiro. Jiro.Commands is a command base and plugin manager designed to facilitate the creation of plugins and custom commands for Jiro. It provides a flexible and efficient way to extend the functionality of your application through the use of plugins.

The plugin management feature of Jiro.Commands provides a standardized way to load and unload plugins, improving the maintainability and scalability of your application. It allows you to quickly add new features to your application without needing to rebuild it from scratch.

In summary, Jiro.Commands is a powerful and versatile library that allows you to extend and optimize the functionality of your Jiro application, quickly and easily.

Plugin creation

To create a plugin, you have to create your own class that will inherit IPlugin interface

public class PluginMain : IPlugin
{
    public string PluginName { get; } = "PluginMain";

    // optional
    public void RegisterAppConfigs(ConfigurationManager builder)
    {
        builder.AddJsonFile("example.config.json", optional: true, reloadOnChange: true);
    }

    // optional
    public void RegisterAppExtensions(IApplicationBuilder app)
    {
        app.UsePluginMiddleware();
    }

    public void RegisterServices(IServiceCollection services)
    {
        services.AddScoped<IPluginService, PluginService>();
    }
}
  • public string PluginName { get; } = "PluginMain"; - This property returns the name of the plugin.

  • public void RegisterAppConfigs(ConfigurationManager builder) - This method is optional and allows the plugin to register configuration files. In this case, an example example.config.json file is registered as a JSON file that can be reloaded on changes.

  • public void RegisterAppExtensions(IApplicationBuilder app) - This method is optional and allows the plugin to register additional middleware for the application. Here, the UsePluginMiddleware method is registered as an extension method for an IApplicationBuilder instance.

  • public void RegisterServices(IServiceCollection services) - This method is used to register services that the plugin provides or requires. In this case, an instance of PluginService class is registered as a service that can be injected using the AddScoped extension method for IServiceCollection.

Custom Controllers

To create a custom controller, you have to create your own class that will inherit BaseController class

public class PluginController : BaseController
{
    public PluginController() { }

    [HttpGet("PluginTest")]
    public IActionResult PluginTest()
    {
        return Ok("Plugin Controller Executed");
    }
}

Custom Commands

Commands have scoped lifetime by default.

[CommandModule("PluginCommand")]
public class PluginCommand : ICommandBase
{
    private readonly IPluginService _pluginService;
    public PluginCommand(IPluginService pluginService)
    {
        _pluginService = pluginService;
    }

    [Command("PluginTest", commandSyntax: "PluginTest", commandDescription: "Tests plugin command")]
    public async Task<ICommandResult> PluginTest()
    {
        _pluginService.ServiceTest();

        await Task.Delay(1000);
        return TextResult.Create("Plugin Command Executed");
    }
}
  • [CommandModule("PluginCommand")] - This attribute is used to define a command module, which acts as a container for commands. In this case, the module name is "PluginCommand".

  • public class PluginCommand : ICommandBase - This class implements the ICommandBase interface and is a command.

  • public PluginCommand(IPluginService pluginService) - The command's constructor injects an instance of IPluginService as a dependency.

  • [Command("PluginTest", commandSyntax: "PluginTest", commandDescription: "Tests plugin command")] - This attribute is used to define a command within the PluginCommand module. Here, the command name is "PluginTest" and it has a description "Tests plugin command". It also provides the command syntax as "PluginTest".

  • return TextResult.Create("Plugin Command Executed"); - Finally, returns the result of the command execution. In this case, it creates a new instance of a TextResult object that contains the string message "Plugin Command Executed".

The requirements for commands:

  • Class must contain [CommandModuleAttribute]
  • Class must inherit ICommandBase
  • Command Method must contain [CommandAttribute] with at least a command name
  • Command Method must return Task<ICommandResult>
  • Use TextResult.Create, ImageResult.Create, GraphResult.Create for creating ICommandResult
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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
3.0.4 190 7/13/2025
3.0.3 116 7/13/2025
3.0.2 97 7/13/2025
3.0.1 103 7/12/2025
1.0.6 434 6/26/2023
1.0.5 320 3/27/2023
1.0.4 298 3/10/2023
1.0.3 295 3/10/2023
1.0.1 291 3/9/2023
1.0.0 280 3/9/2023

Initial