A flexible command and plugin framework for Jiro
Jiro.Commands provides a robust, extensible system for building plugins and runtime commands for the Jiro platform. It enables modular development, dynamic feature loading, and a clean separation of concerns for your application.
- Plugin Management: Standardized loading/unloading of plugins at runtime.
- Runtime Command Creation: Add new commands without rebuilding or redeploying your app.
- Dependency Injection: Full support for DI in commands and plugins.
- Custom Controllers: Easily extend your API surface with plugin controllers.
- Strong Typing & Parsing: Type-safe command parameters and extensible parsing.
- XML Documentation: All public APIs are fully documented for IntelliSense and doc generation.
Install via NuGet Package Manager:
dotnet add package Jiro.CommandsOr via Package Manager Console:
Install-Package Jiro.CommandsCreate a plugin by implementing the IPlugin interface:
public class PluginMain : IPlugin
{
public string PluginName { get; } = "PluginMain";
// Optional: Register configuration files
public void RegisterAppConfigs(ConfigurationManager builder)
=> builder.AddJsonFile("example.config.json", optional: true, reloadOnChange: true);
// Optional: Register middleware
public void RegisterAppExtensions(IApplicationBuilder app)
=> app.UsePluginMiddleware();
// Required: Register services
public void RegisterServices(IServiceCollection services)
=> services.AddScoped<IPluginService, PluginService>();
}Plugin requirements:
- Implement
IPlugin. - Provide a unique
PluginName. - Register any services, configs, or middleware as needed.
Extend the API by inheriting from BaseController:
public class PluginController : BaseController
{
[HttpGet("PluginTest")]
public IActionResult PluginTest() => Ok("Plugin Controller Executed");
}Define commands by using attributes and implementing ICommandBase:
[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");
}
}Command requirements:
- Class must have
[CommandModule]attribute. - Class must implement
ICommandBase. - Command methods must have
[Command]attribute (with at least a name). - Command methods must return
Task<ICommandResult>. - Use
TextResult.Create,ImageResult.Create,JsonResult.Create, orGraphResult.Createfor results.
- All public APIs are documented with XML comments.
- See the source code for detailed usage and extension points.
Contributions, issues, and feature requests are welcome! Please open an issue or pull request on GitHub.
This project uses EditorConfig to maintain consistent coding styles. Make sure your editor supports EditorConfig or install the appropriate extension:
- VS Code: Install the EditorConfig extension
- Visual Studio: Built-in support (2017+)
- Other editors: See EditorConfig.org for editor-specific setup
- Run
dotnet formatbefore committing to ensure code follows the project's style guidelines - The CI pipeline will verify that code formatting is consistent
This project is licensed under the MIT License. See the LICENSE file for details.
