Console help: revert to command listing; hide connect alias.

`help` bare went back to printing the textual list of commands rather
than opening the help screen — the screen is reachable from the
dashboard with `[h]`. This matches how every other CLI handles `help`
and avoids surprising script behaviour.

Added a `hidden` field on `CommandSpec` so registry-level aliases can
be excluded from the listing. `connect` is now hidden (the alias
`plug` is the user-facing name on the dashboard and in `help`).
Both names continue to resolve to the same action; existing scripts
that used `connect` still work.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-15 12:27:38 +02:00
parent ae36026768
commit f62f4a0c9b
2 changed files with 28 additions and 7 deletions

View File

@@ -27,9 +27,28 @@ void Tui::RegisterCommands() {
{{"command name (optional)", Completion::Command}},
[this](const std::vector<std::string> &args) {
if (args.empty()) {
// Bare → open the feature-reference screen.
screen_back_idx = -1;
screen_idx = 6;
// Bare → textual list of commands. The feature-reference
// screen lives at `screen_idx = 6` and is reachable from
// the dashboard with `[h]`.
size_t maxw = 0;
for (const auto &kv : commands) maxw = std::max(maxw, kv.first.size());
auto print_group = [&](const std::string &title, bool want_interactive) {
bool printed_any = false;
for (const auto &kv : commands) {
if (kv.second.hidden) continue;
if (kv.second.interactive != want_interactive) continue;
if (!printed_any) { Print(title); printed_any = true; }
Print(" " + kv.first
+ std::string(maxw - kv.first.size() + 2, ' ')
+ kv.second.description);
}
};
Print("Commands — type `help <name>` for details.");
print_group("Interactive (open a full-screen mode):", true);
print_group("Other:", false);
Print("Keys: Esc cancels a multi-step prompt or returns to the dashboard;");
Print(" Tab completes commands/paths or cycles focus in screens;");
Print(" PageUp/PageDown scroll output, Home/End jump to top/bottom.");
return;
}
const std::string &name = args[0];
@@ -55,9 +74,7 @@ void Tui::RegisterCommands() {
}
},
/*prompt_for_missing=*/ false,
"bare → open the help screen; `help <name>` → textual command help",
/*scriptable=*/ false,
/*interactive=*/ true,
"list commands (or `help <name>` for one command's details)",
};
commands["clear"] = { {}, [this](auto &) { output.clear(); }, true,
"clear the visualization area" };
@@ -571,8 +588,11 @@ void Tui::RegisterCommands() {
};
// UI alias: the dashboard surfaces this command as `plug`. Keep the
// canonical `connect` for script + save/restore stability.
// `plug` is the user-facing name (dashboard shortcut [p]). `connect`
// stays registered for script + save/restore backward compatibility but
// is hidden from `help`.
commands["plug"] = commands["connect"];
commands["plug"].description = "alias of `connect` (UI label used in the dashboard)";
commands["connect"].hidden = true;
commands["explore"] = { {}, [this](auto &) {
if (!sys) { Print("no system: run 'new' first."); return; }

View File

@@ -35,6 +35,7 @@ class Tui {
std::string description;
bool scriptable = true;
bool interactive = false; ///< opens a full-screen mode when called bare
bool hidden = false; ///< don't list in `help` (used by aliases)
};
// ---- Shell state ----