|
|
|
@ -219,28 +219,30 @@ static std::string getScriptHelp(std::string path, std::string helpprefix)
|
|
|
|
|
return "No help available.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::map<string,string> listScripts(PluginManager *plug_mgr, std::string path)
|
|
|
|
|
static void listScripts(PluginManager *plug_mgr, std::map<string,string> &pset, std::string path, bool all, std::string prefix = "")
|
|
|
|
|
{
|
|
|
|
|
std::vector<string> files;
|
|
|
|
|
getdir(path, files);
|
|
|
|
|
|
|
|
|
|
std::map<string,string> pset;
|
|
|
|
|
for (size_t i = 0; i < files.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (hasEnding(files[i], ".lua"))
|
|
|
|
|
{
|
|
|
|
|
std::string help = getScriptHelp(path + files[i], "-- ");
|
|
|
|
|
|
|
|
|
|
pset[files[i].substr(0, files[i].size()-4)] = help;
|
|
|
|
|
pset[prefix + files[i].substr(0, files[i].size()-4)] = help;
|
|
|
|
|
}
|
|
|
|
|
else if (plug_mgr->eval_ruby && hasEnding(files[i], ".rb"))
|
|
|
|
|
{
|
|
|
|
|
std::string help = getScriptHelp(path + files[i], "# ");
|
|
|
|
|
|
|
|
|
|
pset[files[i].substr(0, files[i].size()-3)] = help;
|
|
|
|
|
pset[prefix + files[i].substr(0, files[i].size()-3)] = help;
|
|
|
|
|
}
|
|
|
|
|
else if (all && !files[i].empty() && files[i][0] != '.')
|
|
|
|
|
{
|
|
|
|
|
listScripts(plug_mgr, pset, path+files[i]+"/", all, prefix+files[i]+"/");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool fileExists(std::string path)
|
|
|
|
@ -335,7 +337,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
|
|
|
|
|
con.print("Basic commands:\n"
|
|
|
|
|
" help|?|man - This text.\n"
|
|
|
|
|
" help COMMAND - Usage help for the given command.\n"
|
|
|
|
|
" ls|dir [PLUGIN] - List available commands. Optionally for single plugin.\n"
|
|
|
|
|
" ls|dir [-a] [PLUGIN] - List available commands. Optionally for single plugin.\n"
|
|
|
|
|
" cls - Clear the console.\n"
|
|
|
|
|
" fpause - Force DF to pause.\n"
|
|
|
|
|
" die - Force DF to close immediately\n"
|
|
|
|
@ -469,6 +471,12 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
|
|
|
|
|
}
|
|
|
|
|
else if(first == "ls" || first == "dir")
|
|
|
|
|
{
|
|
|
|
|
bool all = false;
|
|
|
|
|
if (parts.size() && parts[0] == "-a")
|
|
|
|
|
{
|
|
|
|
|
all = true;
|
|
|
|
|
vector_erase_at(parts, 0);
|
|
|
|
|
}
|
|
|
|
|
if(parts.size())
|
|
|
|
|
{
|
|
|
|
|
string & plugname = parts[0];
|
|
|
|
@ -491,7 +499,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
|
|
|
|
|
con.print(
|
|
|
|
|
"builtin:\n"
|
|
|
|
|
" help|?|man - This text or help specific to a plugin.\n"
|
|
|
|
|
" ls [PLUGIN] - List available commands. Optionally for single plugin.\n"
|
|
|
|
|
" ls [-a] [PLUGIN] - List available commands. Optionally for single plugin.\n"
|
|
|
|
|
" cls - Clear the console.\n"
|
|
|
|
|
" fpause - Force DF to pause.\n"
|
|
|
|
|
" die - Force DF to close immediately\n"
|
|
|
|
@ -523,7 +531,8 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve
|
|
|
|
|
con.print(" %-22s- %s\n",(*iter).name.c_str(), (*iter).description.c_str());
|
|
|
|
|
con.reset_color();
|
|
|
|
|
}
|
|
|
|
|
auto scripts = listScripts(plug_mgr, getHackPath() + "scripts/");
|
|
|
|
|
std::map<string, string> scripts;
|
|
|
|
|
listScripts(plug_mgr, scripts, getHackPath() + "scripts/", all);
|
|
|
|
|
if (!scripts.empty())
|
|
|
|
|
{
|
|
|
|
|
con.print("\nscripts:\n");
|
|
|
|
|