Webcmd Guide
Webcmd Guide
The webcmd page is a terminal-style UI at /webcmd/. It shares the site’s theme, uses the default layout, and runs a lightweight command engine written in assets/js/webcmd.js. The interface is inspired by RSC and Greg Travis.
How webcmd works
- Page markup:
webcmd/index.htmlrenders the command input, output, error, and help containers. - Command engine:
assets/js/webcmd.jsparses input, runs commands, and renders output. - Styling:
assets/css/nord.cssprovides the themed UI styles under thewebcmdsection. - Layout:
_layouts/default.htmlincludes the JS bundle so the command engine is available on/webcmd/.
Data flow
- The input form in
webcmd/index.htmlsubmits a command string. assets/js/webcmd.jsintercepts the submit and callsruncmd().runcmd()dispatches to:searches(search shortcuts),shortcuts(simple URL shortcuts),navigation(site navigation shortcuts), or- a function named
cmd_<name>.
output()anderror()print results into#outputand#error.helptext()builds the help table shown in#help.
Adding a new command
Add a new function named cmd_<name> in assets/js/webcmd.js, then add a help entry so it appears in the help panel.
Example:
function cmd_hello(cmd, arg, args)
{
var name = arg || "world";
output("hello " + name);
}
help["hello"] = "print a greeting";
Notes:
cmd,arg, andargsare passed byruncmd().argis the raw argument string;argsis the split array.- Use
output()for normal output anderror()for errors. - To clear output, use
cmd_cls()or calldocument.getElementById("output").innerHTML = "";.
Adding or changing shortcuts
There are three shortcut maps near the top of assets/js/webcmd.js:
navigation: site routes (opens in the same tab).shortcuts: external URLs (opens in a new tab).searches: search providers (builds a query URL and opens in a new tab).
Each shortcut should have a matching entry in the help map if you want it listed in the help panel.
Help panel behavior
helptext() builds the help panel from:
navigation,searches, andshortcuts, plus- every function with a
cmd_prefix found onwindow.
If a command does not appear, add a line to the help map:
help["yourcmd"] = "short description";
Required IDs and hooks
The command engine expects these IDs to exist in webcmd/index.html:
#webcmd-form(form that wraps the input)#line(text input)#output(command output)#error(error output)#help(help panel)#webcmd-help-toggle(help toggle button)
If you rename any of these, update the selectors in assets/js/webcmd.js.