Don't require short script help to start with a space

Ref #742
develop
lethosor 2015-11-09 22:58:46 -05:00
parent 48670251e4
commit 2882422a3e
1 changed files with 10 additions and 5 deletions

@ -261,7 +261,12 @@ static std::string getScriptHelp(std::string path, std::string helpprefix)
std::string help; std::string help;
if (getline(script, help) && if (getline(script, help) &&
help.substr(0,helpprefix.length()) == helpprefix) help.substr(0,helpprefix.length()) == helpprefix)
return help.substr(helpprefix.length()); {
help = help.substr(helpprefix.length());
while (help.size() && help[0] == ' ')
help = help.substr(1);
return help;
}
} }
return "No help available."; return "No help available.";
@ -276,13 +281,13 @@ static void listScripts(PluginManager *plug_mgr, std::map<string,string> &pset,
{ {
if (hasEnding(files[i], ".lua")) if (hasEnding(files[i], ".lua"))
{ {
std::string help = getScriptHelp(path + files[i], "-- "); std::string help = getScriptHelp(path + files[i], "--");
pset[prefix + files[i].substr(0, files[i].size()-4)] = help; pset[prefix + files[i].substr(0, files[i].size()-4)] = help;
} }
else if (plug_mgr->ruby && plug_mgr->ruby->is_enabled() && hasEnding(files[i], ".rb")) else if (plug_mgr->ruby && plug_mgr->ruby->is_enabled() && hasEnding(files[i], ".rb"))
{ {
std::string help = getScriptHelp(path + files[i], "# "); std::string help = getScriptHelp(path + files[i], "#");
pset[prefix + files[i].substr(0, files[i].size()-3)] = help; pset[prefix + files[i].substr(0, files[i].size()-3)] = help;
} }
@ -649,14 +654,14 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, v
} }
string file = findScript(parts[0] + ".lua"); string file = findScript(parts[0] + ".lua");
if ( file != "" ) { if ( file != "" ) {
string help = getScriptHelp(file, "-- "); string help = getScriptHelp(file, "--");
con.print("%s: %s\n", parts[0].c_str(), help.c_str()); con.print("%s: %s\n", parts[0].c_str(), help.c_str());
return CR_OK; return CR_OK;
} }
if (plug_mgr->ruby && plug_mgr->ruby->is_enabled() ) { if (plug_mgr->ruby && plug_mgr->ruby->is_enabled() ) {
file = findScript(parts[0] + ".rb"); file = findScript(parts[0] + ".rb");
if ( file != "" ) { if ( file != "" ) {
string help = getScriptHelp(file, "# "); string help = getScriptHelp(file, "#");
con.print("%s: %s\n", parts[0].c_str(), help.c_str()); con.print("%s: %s\n", parts[0].c_str(), help.c_str());
return CR_OK; return CR_OK;
} }