Update plugins to use CR_WRONG_USAGE where appropriate

develop
Quietust 2013-10-30 15:58:14 -05:00
parent ff939e36bb
commit 463bb8d498
12 changed files with 68 additions and 74 deletions

@ -626,7 +626,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
commands.push_back( commands.push_back(
PluginCommand( PluginCommand(
"autotrade", "Automatically send items in marked stockpiles to trade depot, when trading is possible.", "autotrade", "Automatically send items in marked stockpiles to trade depot, when trading is possible.",
autotrade_cmd, false, "")); autotrade_cmd, false, "Run 'autotrade version' to query the plugin version."));
return CR_OK; return CR_OK;
} }

@ -1183,7 +1183,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
commands.push_back( commands.push_back(
PluginCommand( PluginCommand(
"buildingplan", "Place furniture before it's built", "buildingplan", "Place furniture before it's built",
buildingplan_cmd, false, "")); buildingplan_cmd, false, "Run 'buildingplan debug [on|off]' to toggle debugging, or 'buildingplan version' to query the plugin version."));
planner.initialize(); planner.initialize();
return CR_OK; return CR_OK;

@ -37,7 +37,14 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters);
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("createitem", "Create arbitrary item at the selected unit's feet.", df_createitem)); commands.push_back(PluginCommand("createitem", "Create arbitrary item at the selected unit's feet.", df_createitem, false,
"Syntax: createitem <item> <material> [count]\n"
" <item> - Item token for what you wish to create, as specified in custom\n"
" reactions. If the item has no subtype, omit the :NONE.\n"
" <material> - The material you want the item to be made of, as specified\n"
" in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n"
" PET, and EGG, replace this with a creature ID and caste.\n"
" [count] - How many of the item you wish to create.\n"));
return CR_OK; return CR_OK;
} }
@ -91,17 +98,7 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters)
int count = 1; int count = 1;
if ((parameters.size() < 2) || (parameters.size() > 3)) if ((parameters.size() < 2) || (parameters.size() > 3))
{
out.print("Syntax: createitem <item> <material> [count]\n"
" <item> - Item token for what you wish to create, as specified in custom\n"
" reactions. If the item has no subtype, omit the :NONE.\n"
" <material> - The material you want the item to be made of, as specified\n"
" in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n"
" PET, and EGG, replace this with a creature ID and caste.\n"
" [count] - How many of the item you wish to create.\n"
);
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
}
item_str = parameters[0]; item_str = parameters[0];
material_str = parameters[1]; material_str = parameters[1];

@ -58,6 +58,7 @@ command_result lair(color_ostream &out, std::vector<std::string> & params)
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("lair","Mark the map as a monster lair, preventing item scatter ('lair reset' reverts that).",lair)); commands.push_back(PluginCommand("lair","Mark the map as a monster lair, preventing item scatter.",lair, false,
"Usage: 'lair' to mark entire map as monster lair, 'lair reset' to undo the operation.\n"));
return CR_OK; return CR_OK;
} }

@ -59,12 +59,16 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
liquids_hist.load("liquids.history"); liquids_hist.load("liquids.history");
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"liquids", "Place magma, water or obsidian.", "liquids", "Place magma, water or obsidian.",
df_liquids, true)); // interactive, needs console for prompt df_liquids, true,
"This tool allows placing magma, water and other similar things.\n"
"It is interactive and further help is available when you run it.\n"
"The settings will be remembered until dfhack is closed and you can call\n"
"'liquids-here' (mapped to a hotkey) to paint liquids at the cursor position\n"
"without the need to go back to the dfhack console.\n")); // interactive, needs console for prompt
commands.push_back(PluginCommand( commands.push_back(PluginCommand(
"liquids-here", "Use settings from liquids at cursor position.", "liquids-here", "Use settings from liquids at cursor position.",
df_liquids_here, Gui::cursor_hotkey, // non-interactive, needs ingame cursor df_liquids_here, Gui::cursor_hotkey, // non-interactive, needs ingame cursor
" Identical to pressing enter in liquids, intended for use as keybinding.\n" " This command is intended to be mapped to a hotkey and is identical to pressing Enter in liquids with the current parameters.\n"));
" Can (but doesn't need to) be called while liquids is running in the console."));
return CR_OK; return CR_OK;
} }
@ -157,14 +161,7 @@ command_result df_liquids (color_ostream &out_, vector <string> & parameters)
for(size_t i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ return CR_WRONG_USAGE;
out.print( "This tool allows placing magma, water and other similar things.\n"
"It is interactive and further help is available when you run it.\n"
"The settings will be remembered until dfhack is closed and you can call\n"
"'liquids-here' (mapped to a hotkey) to paint liquids at the cursor position\n"
"without the need to go back to the dfhack console.\n");
return CR_OK;
}
} }
if (!Maps::IsValid()) if (!Maps::IsValid())
@ -375,11 +372,7 @@ command_result df_liquids_here (color_ostream &out, vector <string> & parameters
for(size_t i = 0; i < parameters.size();i++) for(size_t i = 0; i < parameters.size();i++)
{ {
if(parameters[i] == "help" || parameters[i] == "?") if(parameters[i] == "help" || parameters[i] == "?")
{ return CR_WRONG_USAGE;
out << "This command is supposed to be mapped to a hotkey." << endl;
out << "It will use the current/last parameters set in liquids." << endl;
return CR_OK;
}
} }
out.print("Run liquids-here with these parameters: "); out.print("Run liquids-here with these parameters: ");

@ -46,13 +46,19 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
{ {
commands.push_back(PluginCommand("probe", commands.push_back(PluginCommand("probe",
"A tile probe", "A tile probe",
df_probe)); df_probe,
false,
"Hover the cursor over a tile to view its properties.\n"));
commands.push_back(PluginCommand("cprobe", commands.push_back(PluginCommand("cprobe",
"A creature probe", "A creature probe",
df_cprobe)); df_cprobe,
false,
"Select a creature to view its properties.\n"));
commands.push_back(PluginCommand("bprobe", commands.push_back(PluginCommand("bprobe",
"A simple building probe", "A simple building probe",
df_bprobe)); df_bprobe,
false,
"Select a building to view its properties.\n"));
return CR_OK; return CR_OK;
} }

@ -30,7 +30,8 @@ command_result df_regrass (color_ostream &out, vector <string> & parameters);
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("regrass", "Regrows surface grass.", df_regrass)); commands.push_back(PluginCommand("regrass", "Regrows surface grass.", df_regrass, false,
"Specify parameter 'max' to set all grass types to full density, otherwise only one type of grass will be restored per tile.\n"));
return CR_OK; return CR_OK;
} }

@ -76,12 +76,23 @@ DFHACK_PLUGIN("reveal");
DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("reveal","Reveal the map. 'reveal hell' will also reveal hell. 'reveal demon' won't pause.",reveal)); commands.push_back(PluginCommand("reveal","Reveal the map. 'reveal hell' will also reveal hell. 'reveal demon' won't pause.",reveal,false,
commands.push_back(PluginCommand("unreveal","Revert the map to its previous state.",unreveal)); "Reveals the map, by default ignoring hell.\n"
commands.push_back(PluginCommand("revtoggle","Reveal/unreveal depending on state.",revtoggle)); "Options:\n"
commands.push_back(PluginCommand("revflood","Hide all, reveal all tiles reachable from cursor position.",revflood)); "hell - also reveal hell, while forcing the game to pause.\n"
commands.push_back(PluginCommand("revforget", "Forget the current reveal data, allowing to use reveal again.",revforget)); "demon - reveal hell, do not pause.\n"));
commands.push_back(PluginCommand("nopause","Disable pausing (doesn't affect pause forced by reveal).",nopause)); commands.push_back(PluginCommand("unreveal","Revert the map to its previous state.",unreveal,false,
"Reverts the previous reveal operation, hiding the map again.\n"));
commands.push_back(PluginCommand("revtoggle","Reveal/unreveal depending on state.",revtoggle,false,
"Toggles between reveal and unreveal.\n"));
commands.push_back(PluginCommand("revflood","Hide all, reveal all tiles reachable from cursor position.",revflood,false,
"This command hides the whole map. Then, starting from the cursor,\n"
"reveals all accessible tiles. Allows repairing parma-revealed maps.\n"));
commands.push_back(PluginCommand("revforget", "Forget the current reveal data, allowing to use reveal again.",revforget,false,
"Forget the current reveal data, allowing to use reveal again.\n"));
commands.push_back(PluginCommand("nopause","Disable pausing (doesn't affect pause forced by reveal).",nopause,false,
"Disable pausing (doesn't affect pause forced by reveal).\n"
"Activate with 'nopause 1', deactivate with 'nopause 0'.\n"));
return CR_OK; return CR_OK;
} }
@ -160,14 +171,7 @@ command_result reveal(color_ostream &out, vector<string> & params)
if(params[i]=="hell") if(params[i]=="hell")
no_hell = false; no_hell = false;
else if(params[i] == "help" || params[i] == "?") else if(params[i] == "help" || params[i] == "?")
{ return CR_WRONG_USAGE;
out.print("Reveals the map, by default ignoring hell.\n"
"Options:\n"
"hell - also reveal hell, while forcing the game to pause.\n"
"demon - reveal hell, do not pause.\n"
);
return CR_OK;
}
} }
if(params.size() && params[0] == "hell") if(params.size() && params[0] == "hell")
{ {
@ -254,10 +258,7 @@ command_result unreveal(color_ostream &out, vector<string> & params)
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ return CR_WRONG_USAGE;
out.print("Reverts the previous reveal operation, hiding the map again.\n");
return CR_OK;
}
} }
if(!revealed) if(!revealed)
{ {
@ -330,12 +331,7 @@ command_result revflood(color_ostream &out, vector<string> & params)
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ return CR_WRONG_USAGE;
out.print("This command hides the whole map. Then, starting from the cursor,\n"
"reveals all accessible tiles. Allows repairing parma-revealed maps.\n"
);
return CR_OK;
}
} }
CoreSuspender suspend; CoreSuspender suspend;
uint32_t x_max,y_max,z_max; uint32_t x_max,y_max,z_max;
@ -482,10 +478,7 @@ command_result revforget(color_ostream &out, vector<string> & params)
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ return CR_WRONG_USAGE;
out.print("Forget the current reveal data, allowing to use reveal again.\n");
return CR_OK;
}
} }
if(!revealed) if(!revealed)
{ {

@ -130,11 +130,15 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
{ {
case 0: case 0:
printHelp(out); printHelp(out);
break; return CR_WRONG_USAGE;
case 1: case 1:
par = parameters[0]; par = parameters[0];
if(par == "help") printHelp(out); if ((par == "help") || (par == "?"))
else if(par == "?") printHelp(out); {
printHelp(out);
return CR_WRONG_USAGE;
}
else if(par == "start") else if(par == "start")
{ {
running = true; running = true;
@ -239,6 +243,7 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
break; break;
default: default:
printHelp(out); printHelp(out);
return CR_WRONG_USAGE;
break; break;
} }

@ -292,7 +292,8 @@ DFHACK_PLUGIN("showmood");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood)); commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood, false,
"Run this command without any parameters to display information on the currently active Strange Mood."));
return CR_OK; return CR_OK;
} }

@ -1002,7 +1002,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
commands.push_back( commands.push_back(
PluginCommand( PluginCommand(
"stocks", "An improved stocks display screen", "stocks", "An improved stocks display screen",
stocks_cmd, false, "")); stocks_cmd, false, "Run 'stocks show' open the stocks display screen, or 'stocks version' to query the plugin version."));
ViewscreenStocks::reset(); ViewscreenStocks::reset();

@ -23,7 +23,9 @@ DFHACK_PLUGIN("tubefill");
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
commands.push_back(PluginCommand("tubefill","Fill in all the adamantine tubes again.",tubefill)); commands.push_back(PluginCommand("tubefill","Fill in all the adamantine tubes again.",tubefill, false,
"Replenishes mined out adamantine and hollow adamantine tubes.\n"
"May cause !!FUN!!\n"));
return CR_OK; return CR_OK;
} }
@ -39,12 +41,7 @@ command_result tubefill(color_ostream &out, std::vector<std::string> & params)
for(size_t i = 0; i < params.size();i++) for(size_t i = 0; i < params.size();i++)
{ {
if(params[i] == "help" || params[i] == "?") if(params[i] == "help" || params[i] == "?")
{ return CR_WRONG_USAGE;
out.print("Replenishes mined out adamantine and hollow adamantine tubes.\n"
"May cause !!FUN!!\n"
);
return CR_OK;
}
} }
CoreSuspender suspend; CoreSuspender suspend;