ref: 1c65e9795d3a51c26a87296d53b0ebe9efdc7719
dir: /tools/man.tool/
static char*
lookman(OToolcall tc, void*)
{
JSON *j, *jk;
char *s, *cmd;
if (!allowed(tc, 0))
return abortcall(tc);
j = jsonparse(tc.arguments);
jk = jsonbyname(j, "keyword");
s = jsonstr(jk);
if (!(s && s[0]))
return strdup("lookman: missing keyword");
cmd = smprint("lookman '%s'", s);
jsonfree(j);
s = callfunc(cmd);
free(cmd);
return s;
}
static char *lookmandesc = "Search the man pages for the specified keyword. The result shows the name of the man page and the section number.";
static char *lookmanargs = ""
%%json
{
"type": "object",
"properties": {
"keyword": {
"type": "string",
"description": "keyword to search for in the man pages"
}
},
"required": [ "keyword" ]
}
%/json
;
static char*
man(OToolcall tc, void*)
{
JSON *j, *js, *jn;
char *sec, *name;
char *s, *cmd;
if (!allowed(tc, 0))
return abortcall(tc);
j = jsonparse(tc.arguments);
js = jsonbyname(j, "section");
jn = jsonbyname(j, "name");
sec = jsonstr(js);
name = jsonstr(jn);
if (!(sec && name))
return strdup("man: missing section or name");
if (!(sec[0] && name[0]))
return strdup("man: empty section or name");
cmd = smprint("man '%s' '%s'", sec, name);
jsonfree(j);
s = callfunc(cmd);
free(cmd);
return s;
}
static char *mandesc = "get the contents of the specified man page.";
static char *manargs = ""
%%json
{
"type": "object",
"properties": {
"section": {
"type": "string",
"description": "section number of the man page"
},
"name": {
"type": "string",
"description": "name of the section"
}
},
"required": [ "section", "name" ]
}
%/json
;