This package is experimental. It is not part of the official NATS ecosystem and is published exclusively in Orbit .NET to gauge interest and address community requests. The API may change or the package may be removed in a future release.
A library for building NATS CLI plugins as AOT-compiled native binaries. Extends System.CommandLine with an entry point that handles the fisk introspection protocol (JSON handshake) and provides NATS CLI context file reading.
Define commands with System.CommandLine and call RunNatsCliPluginAsync():
var root = new RootCommand("My plugin");
root.Add(listCommand);
return await root.RunNatsCliPluginAsync(args, new NatsCliPluginOptions
{
Name = "myplugin",
Version = "1.0.0",
});Load NATS CLI context files for connection settings via the Synadia.Orbit.NatsContext dependency:
var ctx = NatsContext.Load();
await using var nats = await ctx.ConnectAsync();To create a NATS CLI plugin, follow these steps:
- Create a new .NET console application.
- Add a reference to the
Synadia.Orbit.NatsCli.PluginNuGet package. - Define your commands using System.CommandLine.
- Use
RunNatsCliPluginAsync()extension method on yourRootCommandto handle the plugin execution. - Publish your application.
- Register your plugin with NATS CLI using the
nats plugins registercommand.
An example NATS CLI plugin is available in the Synadia Orbit .NET repository under tools/peek.
> dotnet publish -o /path/to/.natscli-plugins
> nats plugins register peek /path/to/.natscli-plugins/peek.exe
> nats peek info
For more information, see the orbit.net documentation.