Make the help command work with commands too. (moved to cmd.c while I

was at it)
This commit is contained in:
Adam Olsen 2001-07-30 01:01:39 +00:00
parent dbb339651d
commit 0219bcb4c8
2 changed files with 34 additions and 23 deletions

View file

@ -451,6 +451,7 @@ Cmd_UnAlias_f (void)
}
}
/*
COMMAND EXECUTION
*/
@ -957,6 +958,38 @@ Cmd_CmdList_f (void)
Con_Printf ("------------\n%d commands\n", i);
}
void
Cmd_Help_f (void)
{
const char *name;
cvar_t *var;
cmd_function_t *cmd;
if (Cmd_Argc () != 2) {
Con_Printf ("usage: help <cvar/command>\n");
return;
}
name = Cmd_Argv (1);
for (cmd = cmd_functions; cmd && strcasecmp (name, cmd->name); cmd = cmd->next)
;
if (cmd) {
Con_Printf ("%s\n", cmd->description);
return;
}
var = Cvar_FindVar (name);
if (!var)
var = Cvar_FindAlias (name);
if (var) {
Con_Printf ("%s\n", var->description);
return;
}
Con_Printf ("variable/command not found\n");
}
static void
cmd_alias_free (void *_a, void *unused)
{
@ -1011,6 +1044,7 @@ Cmd_Init (void)
Cmd_AddCommand ("unalias", Cmd_UnAlias_f, "Remove the selected alias");
Cmd_AddCommand ("wait", Cmd_Wait_f, "Wait a game tic");
Cmd_AddCommand ("cmdlist", Cmd_CmdList_f, "List all commands");
Cmd_AddCommand ("help", Cmd_Help_f, "Display help for a command or variable");
}

View file

@ -433,28 +433,6 @@ Cvar_Toggle_f (void)
Cvar_Set (var, var->int_val ? "0" : "1");
}
void
Cvar_Help_f (void)
{
const char *var_name;
cvar_t *var;
if (Cmd_Argc () != 2) {
Con_Printf ("usage: help <cvar>\n");
return;
}
var_name = Cmd_Argv (1);
var = Cvar_FindVar (var_name);
if (!var)
var = Cvar_FindAlias (var_name);
if (var) {
Con_Printf ("%s\n", var->description);
return;
}
Con_Printf ("variable not found\n");
}
void
Cvar_CvarList_f (void)
{
@ -527,7 +505,6 @@ Cvar_Init (void)
Cmd_AddCommand ("setrom", Cvar_Setrom_f, "Set the selected variable and make it read only, useful on the command line.\n"
"(+setrom variablename setting)");
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "Toggle a cvar on or off");
Cmd_AddCommand ("help", Cvar_Help_f, "Display quake help");
Cmd_AddCommand ("cvarlist", Cvar_CvarList_f, "List all cvars");
}