Files
OmniRoute/examples/omniroute-cmd-hello/index.mjs
diegosouzapw b3e5ee3333 feat(cli): fase 9.4 — plugin system (omniroute-cmd-*)
Adds plugin discovery, loading, and management to the omniroute CLI.

- bin/cli/plugins.mjs: discoverPlugins / loadPlugins / buildPluginContext
- bin/cli/commands/plugin.mjs: list / install / remove / info / search / update / scaffold
- examples/omniroute-cmd-hello/: minimal working plugin example
- docs/dev/plugins.md: plugin API contract and authoring guide
- .env.example + ENVIRONMENT.md: document OMNIROUTE_PLUGIN_PATH
2026-05-15 05:11:18 -03:00

29 lines
860 B
JavaScript

export const meta = {
name: "hello",
version: "0.1.0",
description: "Example OmniRoute plugin — greets the user and shows server health",
omnirouteApi: ">=4.0.0",
};
export function register(program, ctx) {
program
.command("hello")
.description(meta.description)
.option("-n, --name <name>", "Name to greet", "World")
.action(async (opts, cmd) => {
const gOpts = cmd.optsWithGlobals();
process.stdout.write(`Hello, ${opts.name}! 👋\n`);
try {
const res = await ctx.apiFetch("/api/health", {
baseUrl: gOpts.baseUrl,
apiKey: gOpts.apiKey,
});
const health = await res.json();
ctx.emit({ greeting: `Hello, ${opts.name}!`, health }, gOpts);
} catch {
ctx.emit({ greeting: `Hello, ${opts.name}!`, health: "unavailable" }, gOpts);
}
});
}