Double up /help for server help

While the automatic search via LESS is neat, I don't think it's very
useful. Just always open the manual to the COMMANDS section, and fix it
to append to LESS rather than replace it.
weechat-hashes
C. McEnroe 2020-10-02 19:38:37 -04:00
parent f3a56b0d01
commit f7f5acbbe2
4 changed files with 31 additions and 4 deletions

View File

@ -1,4 +1,4 @@
.Dd September 30, 2020 .Dd October 2, 2020
.Dt CATGIRL 1 .Dt CATGIRL 1
.Os .Os
. .
@ -338,12 +338,17 @@ with
and interpret its output and interpret its output
as input to the current window, as input to the current window,
including as commands. including as commands.
.It Ic /help Op Ar search .It Ic /help
View this manual. View this manual.
Type Type
.Ic q .Ic q
to return to to return to
.Nm . .Nm .
.It Ic /help Ar topic
List the server help for a topic.
Try
.Ic /help index
for a list of topics.
.It Ic /ignore Op Ar pattern .It Ic /ignore Op Ar pattern
List message filtering patterns List message filtering patterns
or temporarily add a pattern. or temporarily add a pattern.

1
chat.h
View File

@ -241,6 +241,7 @@ extern struct Replies {
uint away; uint away;
uint ban; uint ban;
uint excepts; uint excepts;
uint help;
uint invex; uint invex;
uint join; uint join;
uint list; uint list;

View File

@ -421,14 +421,20 @@ static void commandExec(uint id, char *params) {
static void commandHelp(uint id, char *params) { static void commandHelp(uint id, char *params) {
(void)id; (void)id;
uiHide();
if (params) {
ircFormat("HELP :%s\r\n", params);
replies.help++;
return;
}
uiHide();
pid_t pid = fork(); pid_t pid = fork();
if (pid < 0) err(EX_OSERR, "fork"); if (pid < 0) err(EX_OSERR, "fork");
if (pid) return; if (pid) return;
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), "ip%s$", (params ?: "COMMANDS")); snprintf(buf, sizeof(buf), "%spCOMMANDS$", (getenv("LESS") ?: ""));
setenv("LESS", buf, 1); setenv("LESS", buf, 1);
execlp("man", "man", "1", "catgirl", NULL); execlp("man", "man", "1", "catgirl", NULL);
dup2(utilPipe[1], STDERR_FILENO); dup2(utilPipe[1], STDERR_FILENO);

View File

@ -302,6 +302,18 @@ static void handleErrorNoMOTD(struct Message *msg) {
(void)msg; (void)msg;
} }
static void handleReplyHelp(struct Message *msg) {
require(msg, false, 3);
if (!replies.help) return;
urlScan(Network, msg->nick, msg->params[2]);
uiWrite(Network, Warm, tagTime(msg), msg->params[2]);
}
static void handleReplyEndOfHelp(struct Message *msg) {
(void)msg;
if (replies.help) replies.help--;
}
static void handleJoin(struct Message *msg) { static void handleJoin(struct Message *msg) {
require(msg, true, 1); require(msg, true, 1);
uint id = idFor(msg->params[0]); uint id = idFor(msg->params[0]);
@ -1253,6 +1265,9 @@ static const struct Handler {
{ "478", handleErrorBanListFull }, { "478", handleErrorBanListFull },
{ "482", handleErrorChanopPrivsNeeded }, { "482", handleErrorChanopPrivsNeeded },
{ "671", handleReplyWhoisGeneric }, { "671", handleReplyWhoisGeneric },
{ "704", handleReplyHelp },
{ "705", handleReplyHelp },
{ "706", handleReplyEndOfHelp },
{ "900", handleReplyLoggedIn }, { "900", handleReplyLoggedIn },
{ "904", handleErrorSASLFail }, { "904", handleErrorSASLFail },
{ "905", handleErrorSASLFail }, { "905", handleErrorSASLFail },