搜索

PythonReactSEOPDF
GitHub Skill

daemon-command-extension

Instructions for adding a new command to the AutomateLinux daemon.

yanivprusman☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Adding a New Daemon Command

Follow these steps to extend the daemon's capabilities with a new command.

1. Define Constants

Open daemon/include/Constants.h and add definitions for your command and any unique arguments.

#define COMMAND_MY_NEW_ACTION "myNewAction"
#define COMMAND_ARG_MY_PARAM "myParam"

2. Implement the Handler

In daemon/src/mainCommand.cpp, implement a handler function. The function must take a const json & and return a CmdResult.

CmdResult handleMyNewAction(const json &command) {
    string param = command[COMMAND_ARG_MY_PARAM].get<string>();
    // ... implement logic ...
    return CmdResult(0, "Action successful: " + param + "\n");
}

3. Register the Command Signature

In daemon/src/mainCommand.cpp, locate the COMMAND_REGISTRY array and add your command's signature (name and required arguments).

const CommandSignature COMMAND_REGISTRY[] = {
    // ...
    CommandSignature(COMMAND_MY_NEW_ACTION, {COMMAND_ARG_MY_PARAM}),
};

4. Register the Dispatcher Handler

In daemon/src/mainCommand.cpp, locate the COMMAND_HANDLERS array and map your command string to its handler function.

static const CommandDispatch COMMAND_HANDLERS[] = {
    // ...
    {COMMAND_MY_NEW_ACTION, handleMyNewAction},
};

5. Build and Test

Rebuild the daemon and test your new command using the terminal d (or daemon send) command.

bd
d send myNewAction --myParam "hello"

[!TIP] Use CmdResult(0, ...) for success and CmdResult(1, ...) for errors. The second argument is the response string sent back to the client.

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!