import { CommandTree, Command } from "@clusterio/lib"; //%// We do not check for multi context here because it doesn't make sense to have a ctl without messages import { PluginExampleEvent, PluginExampleRequest } from "./messages.js"; /* eslint-disable no-console */ const pluginCommands = new CommandTree({ name: "__plugin_name__", description: "The default description I forgot to change", }); pluginCommands.add(new Command({ definition: ["my-command ", "My command description that I really should change", (yargs) => { yargs.positional("foo", { describe: "foo is foo!", type: "string" }); }], handler: async function(args, ctl) { const response = await ctl.sendTo("controller", new PluginExampleRequest(args.foo, [1, 2, 3])); console.log(response); console.log(args); }, })); /* eslint-enable no-console */ export default async function loadCtlPlugin(context) { context.hooks.addCommands.attach(context.plugin.name, async (rootCommand) => { rootCommand.add(pluginCommands); }); }