Author Topic: Apropos command for DS  (Read 2339 times)

Offline Archaegeo

  • Acquaintance
  • *
  • Posts: 33
    • View Profile
Apropos command for DS
« on: January 01, 2008, 08:41:59 pm »
The following code adds apropos support for DS. Note that this is limited, and will only search through the help indexed files.
Syntax: apropos <name>

apropos scan

[creator commands]:  scan
[Autodoc functions]:  doc_d/scan_mudlib

This will really help folks looking for information and searching for help since you do not need to know the full help name or page through all the docs.  Also, if you use the autodoc system I posted earlier frequently, it makes scanning it quicker too.

Add the following function anywhere in /daemon/help.c
Code: [Select]
mapping AllIndices(){
  mapping ret;
  ret = Indices;
  return ret;

Make the following command /secure/cmds/creators/apropos.c
Code: [Select]
/* Do not remove the headers from this file! see /USAGE for more info. */
// Modified from Lima 1.05b by Archaegeo on 1/1/08 for Dead Souls Lib

#include <lib.h>
#include <daemons.h>
#define MIN_LEN 3

mixed apropos(string s);

mixed cmd(string s) {
    string yt;
    if (!s)
        write("apropos <string>\n\n"
          "Returns information on which mudlib functions contain the\n"
          "keyword passed, including a short description.\n");
    if (strlen(s)<MIN_LEN)
        write("Please find a bigger search criteria (min. "+MIN_LEN+
          " letters).\n");
    if (yt=="\n")
        write("No help files match your word.\n");
    return 1;

//Returns information on which help files contain the
//keyword passed, including a short description.

mixed apropos(string s)
    mapping filer=([]);
    mapping topics;
    string output="";
    string *st;
    string pwd;

        error("Apropos whines about help_d not giving any info out.\n");
    foreach (string key,string *files in topics)
        foreach(string d in topics[key]) {
            if (strsrch(d,s)!=-1)
                output += "[" + key + "]:  " + d +"\n";
    return output;

string GetHelp(string str) {
    return ("Syntax: <apropos <name>>\n\n"
      "Pages through the help file names that have been indexed for <name>.\n"+
      "See also: help index");