View Categories

Overriding System Commands

2 min read

Every command in the Cointacted Social Terminal is defined in the JavaScript registry, which means developers (or add-ons) can override any built-in command with custom behavior.

This gives you complete control over the terminal, allowing you to replace, extend, or modify:

  • built-in commands
  • wallet commands
  • admin/debug commands
  • fun commands
  • site/user commands
  • command groups
  • metadata

This article explains exactly how to override commands safely.


1. How Commands Are Stored #

Every command is stored in:

CointactedSocialTerminalTerminal.registry

For example:

registry.help
registry.wallet
registry.echo
registry.random

This makes overriding extremely simple.


2. Overriding a Built-In Command #

To override a command, you simply assign a new function to its registry key:

CointactedSocialTerminalTerminal.registry.help = function(input) {
    cointacted_social_terminal_append_line("This help message is overridden.", "error");
};

Now typing:

help

prints your version instead of the core’s.


3. Extending a Command Instead of Replacing It #

If you want to extend instead of override, wrap the original:

const original = CointactedSocialTerminalTerminal.registry.welcome;

CointactedSocialTerminalTerminal.registry.welcome = function(input) {
    // custom logic BEFORE:
    cointacted_social_terminal_append_line("Custom header...", "system");

    // run original:
    original(input);

    // custom logic AFTER:
    cointacted_social_terminal_append_line("Custom footer!", "success");
};

This lets you:

✔ insert custom lines #

✔ add branding #

✔ add advanced logic #

✔ append or prepend behavior #

✔ inject dynamic data #


4. Overriding Aliases Automatically #

If a command has aliases (e.g., clear and cls), overriding one does NOT override the other.

You must override each alias:

registry.clear = customHandler;
registry.cls = customHandler;

Aliases are independent keys pointing to the same function at registration — not magically linked.


5. Overriding Commands Based on User Roles #

You can override a command based on user permissions by checking roles in JS.

Example: change how the admin debugging command works for non-admins:

const originalAdmin = CointactedSocialTerminalTerminal.registry.admin;

CointactedSocialTerminalTerminal.registry.admin = function(input) {
    const isAdmin = CointactedSocialTerminalTerminal.user?.is_admin;

    if (!isAdmin) {
        return cointacted_social_terminal_append_line(
            "You must be an administrator to run this command.",
            "error"
        );
    }

    originalAdmin(input);
};

This uses the user data your plugin already exposes client-side.


6. Overriding WALLET Commands #

You can override Web3-related commands to integrate:

  • custom chains
  • EVM logic
  • Solana logic
  • RPC endpoints
  • balances
  • Social Mining reward info

Example:

CointactedSocialTerminalTerminal.registry.wallet = function(input) {
    fetch('/wp-json/myplugin/wallet-data')
        .then(r => r.json())
        .then(data => {
            cointacted_social_terminal_append_line(`Wallet: ${data.address}`, "wallet");
        });
};

7. Overriding FUN Commands (for branding or engagement) #

Example: replacing hi:

CointactedSocialTerminalTerminal.registry.hi = function() {
    cointacted_social_terminal_append_line("Welcome to Cointacted 🎉", "fun");
};

Example: replacing dice with custom logic:

CointactedSocialTerminalTerminal.registry.dice = function() {
    cointacted_social_terminal_append_line("Dice rolling disabled.", "error");
};

8. Overriding the “Command Not Found” Handler #

Your plugin centralizes this inside the command dispatcher.

Developers can override it like this:

CointactedSocialTerminalTerminal.command_not_found = function(cmd) {
    cointacted_social_terminal_append_line(
        `Custom: Command '${cmd}' does not exist.`,
        "error"
    );
};

This allows:

  • custom styling
  • suggestions
  • redirecting to other commands
  • running fallback logic

9. Overriding Help Output for Custom Documentation #

Developers can replace the entire help system:

CointactedSocialTerminalTerminal.registry.help = function() {
    cointacted_social_terminal_append_line("Custom help index:", "system");
    cointacted_social_terminal_append_line("- docs: https://yourdocs.com", "system");
    cointacted_social_terminal_append_line("- support: https://yourhelp.com", "system");
};

Or you can wrap the original (best practice).


10. Warnings & Best Practices #

✔ DO override commands for: #

  • branding
  • additional functionality
  • custom logic
  • better UX
  • integrating APIs
  • add-on extensions

❌ DO NOT override commands for: #

  • security bypass
  • hiding essential behavior
  • removing required output
  • rewriting registry metadata incorrectly

✔ DO wrap originals when possible #

This maintains:

  • help integration
  • aliases
  • search
  • command grouping
  • metadata

Summary #

Overriding system commands allows developers to:

✔ replace built-in commands #

✔ extend or wrap existing logic #

✔ customize terminal behavior #

✔ inject branding #

✔ integrate APIs or Web3 #

✔ modify help, wallet, fun, or admin commands #

✔ override “command not found” behavior #

The registry-based system makes overriding simple, flexible, and powerful.

Leave a Reply

Your email address will not be published. Required fields are marked *