- 1. Where to Add Custom Commands
- 2. Basic Command Registration
- 3. Understanding the Command "input" Object
- 4. Adding Commands with Arguments
- 5. Command Aliases
- 6. Adding Multi-Line Output
- 7. Valid Output Types
- 8. Async & API-Based Commands
- 9. Adding Commands to Specific Groups (Optional)
- 10. Overriding Built-In Commands
- Summary
This is the most important part of the Developer Guide:
how to create your own commands and extend the terminal with custom logic.
Everything in this article is based entirely on the real implementation inside your plugin.
1. Where to Add Custom Commands #
You can register custom commands from any JavaScript file that loads after the terminal.
Recommended locations:
✔ Child theme (functions.php + JS file) #
✔ Custom plugin #
✔ Cointacted add-on (official extension architecture) #
Enqueue your script so it loads after the terminal bundle:
wp_enqueue_script(
'my-terminal-ext',
get_stylesheet_directory_uri() . '/terminal-ext.js',
['cointacted-social-terminal-js'],
'1.0',
true
);
Inside terminal-ext.js, you can now register commands.
2. Basic Command Registration #
Every command is added to the registry:
CointactedSocialTerminalTerminal.registry.mycommand = function(input) {
cointacted_social_terminal_append_line("My command executed!", "system");
};
This makes the command available instantly:
mycommand
3. Understanding the Command “input” Object #
When a user types a command, the terminal passes an input object:
{
raw: "echo Hello world",
cmd: "echo",
args: ["Hello", "world"]
}
You can use:
input.cmd→ the command nameinput.args→ array of argumentsinput.raw→ the entire string the user typed
Example:
CointactedSocialTerminalTerminal.registry.say = function(input) {
const text = input.args.join(" ");
cointacted_social_terminal_append_line(text, "system");
};
Usage:
say Hello world
4. Adding Commands with Arguments #
Arguments are automatically parsed.
Example:
CointactedSocialTerminalTerminal.registry.add = function(input) {
const a = parseFloat(input.args[0]);
const b = parseFloat(input.args[1]);
if (isNaN(a) || isNaN(b)) {
return cointacted_social_terminal_append_line("Usage: add <number> <number>", "error");
}
cointacted_social_terminal_append_line(a + b, "success");
};
Usage:
add 3 5
Produces:
8
5. Command Aliases #
You can define aliases easily:
const handler = function(input) {
cointacted_social_terminal_append_line("Same command!", "system");
};
CointactedSocialTerminalTerminal.registry.maincmd = handler;
CointactedSocialTerminalTerminal.registry.mc = handler;
CointactedSocialTerminalTerminal.registry.alias = handler;
All of these work:
maincmd
mc
alias
Aliases also show up in help and search.
6. Adding Multi-Line Output #
You can print multiple lines in sequence:
CointactedSocialTerminalTerminal.registry.info = function(input) {
cointacted_social_terminal_append_line("Line 1", "system");
cointacted_social_terminal_append_line("Line 2", "system");
cointacted_social_terminal_append_line("Line 3", "success");
};
7. Valid Output Types #
Your plugin supports multiple output types:
"system""success""error""wallet""fun""admin"- custom types (via CSS)
Example:
cointacted_social_terminal_append_line("All good!", "success");
These automatically apply correct coloring/formatting.
8. Async & API-Based Commands #
Commands can use fetch() or async logic:
CointactedSocialTerminalTerminal.registry.weather = async function(input) {
const city = input.args[0] || "London";
const res = await fetch(`https://api.example.com/weather/${city}`);
const data = await res.json();
cointacted_social_terminal_append_line(`Weather: ${data.temp}°C`, "system");
};
Usage:
weather Berlin
Async commands work naturally — the terminal does not block.
9. Adding Commands to Specific Groups (Optional) #
The help system reads metadata stored internally.
If you want your command to appear under a group:
Add metadata:
CointactedSocialTerminalTerminal.commands_meta.mycommand = {
group: "TOOLS",
description: "My custom tool command.",
alias: []
};
This is optional — without metadata, the command still works normally.
10. Overriding Built-In Commands #
To override a core command:
CointactedSocialTerminalTerminal.registry.help = function(input) {
cointacted_social_terminal_append_line("Custom help override", "error");
};
Your version replaces the built-in one instantly.
Use with caution.
Summary #
To create custom commands you need:
✔ JS file loaded after the terminal #
✔ Add entry to command registry #
✔ Use input.args for arguments #
✔ Use append_line() to print output #
✔ Optionally add aliases #
✔ Optionally add metadata for help grouping #
✔ Async commands fully supported #
Developing for the terminal is fast, simple, and powerful.