summaryrefslogtreecommitdiff
path: root/core/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/builtins.zig')
-rw-r--r--core/builtins.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/core/builtins.zig b/core/builtins.zig
index b7e1a111..81ec4c2b 100644
--- a/core/builtins.zig
+++ b/core/builtins.zig
@@ -1520,12 +1520,24 @@ pub const Tutor = struct {
}
};
-/// Open the help: every key and every builtin.
+/// Show every builtin with its keys and documentation, or one builtin's alone.
+///
+/// `Help <name>`: that builtin alone, its keys spelled out, what it acts on
+/// and its line for a shell (`Help Diff`); a setting or an addon's word the
+/// same. `Help <keys>`: the builtins under SPC and those keys (`Help l`, as
+/// `SPC l ?` shows them). Each fills the one +Help: a second Help replaces
+/// its text.
pub const Help = struct {
pub const scope: Scope = .session;
+ pub const takes_arg = true;
pub const output: OutputTraits = .{ .name = config.help_buffer };
pub fn run(c: Ctx) void {
- panes.Output.openHelp(c.p, c.id, "") catch |err| c.p.reportError(.at(c.id), "help", err);
+ const what = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
+ if (what.len == 0) return panes.Output.openHelp(c.p, c.id, "") catch |err| c.p.reportError(.at(c.id), "help", err);
+ const found = panes.Output.openHelpOn(c.p, c.id, what) catch |err| return c.p.reportError(.at(c.id), "help", err);
+ if (found) return;
+ var said: pardes.Kind.Buf(128) = .{};
+ c.p.reportFailure(c.id, said.print("Help: {s}: no such builtin, nor SPC keys", .{what[0..@min(what.len, 64)]}));
}
};