|
|
@ -279,19 +279,24 @@ static void listScripts(PluginManager *plug_mgr, std::map<string,string> &pset,
|
|
|
|
std::vector<string> files;
|
|
|
|
std::vector<string> files;
|
|
|
|
Filesystem::listdir(path, files);
|
|
|
|
Filesystem::listdir(path, files);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
path += '/';
|
|
|
|
for (size_t i = 0; i < files.size(); i++)
|
|
|
|
for (size_t i = 0; i < files.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (hasEnding(files[i], ".lua"))
|
|
|
|
if (hasEnding(files[i], ".lua"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string help = getScriptHelp(path + files[i], "--");
|
|
|
|
string help = getScriptHelp(path + files[i], "--");
|
|
|
|
|
|
|
|
string key = prefix + files[i].substr(0, files[i].size()-4);
|
|
|
|
pset[prefix + files[i].substr(0, files[i].size()-4)] = help;
|
|
|
|
if (pset.find(key) == pset.end()) {
|
|
|
|
|
|
|
|
pset[key] = 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], "#");
|
|
|
|
string help = getScriptHelp(path + files[i], "#");
|
|
|
|
|
|
|
|
string key = prefix + files[i].substr(0, files[i].size()-3);
|
|
|
|
pset[prefix + files[i].substr(0, files[i].size()-3)] = help;
|
|
|
|
if (pset.find(key) == pset.end()) {
|
|
|
|
|
|
|
|
pset[key] = help;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (all && !files[i].empty() && files[i][0] != '.')
|
|
|
|
else if (all && !files[i].empty() && files[i][0] != '.')
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -300,6 +305,14 @@ static void listScripts(PluginManager *plug_mgr, std::map<string,string> &pset,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void listAllScripts(map<string, string> &pset, bool all)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vector<string> paths;
|
|
|
|
|
|
|
|
Core::getInstance().getScriptPaths(&paths);
|
|
|
|
|
|
|
|
for (string path : paths)
|
|
|
|
|
|
|
|
listScripts(Core::getInstance().getPluginManager(), pset, path, all);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
namespace {
|
|
|
|
struct ScriptArgs {
|
|
|
|
struct ScriptArgs {
|
|
|
|
const string *pcmd;
|
|
|
|
const string *pcmd;
|
|
|
@ -418,7 +431,7 @@ static bool try_autocomplete(color_ostream &con, const std::string &first, std::
|
|
|
|
bool all = (first.find('/') != std::string::npos);
|
|
|
|
bool all = (first.find('/') != std::string::npos);
|
|
|
|
|
|
|
|
|
|
|
|
std::map<string, string> scripts;
|
|
|
|
std::map<string, string> scripts;
|
|
|
|
listScripts(plug_mgr, scripts, Core::getInstance().getHackPath() + "scripts/", all);
|
|
|
|
listAllScripts(scripts, all);
|
|
|
|
for (auto iter = scripts.begin(); iter != scripts.end(); ++iter)
|
|
|
|
for (auto iter = scripts.begin(); iter != scripts.end(); ++iter)
|
|
|
|
if (iter->first.substr(0, first.size()) == first)
|
|
|
|
if (iter->first.substr(0, first.size()) == first)
|
|
|
|
possible.push_back(iter->first);
|
|
|
|
possible.push_back(iter->first);
|
|
|
@ -907,7 +920,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, v
|
|
|
|
con.reset_color();
|
|
|
|
con.reset_color();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::map<string, string> scripts;
|
|
|
|
std::map<string, string> scripts;
|
|
|
|
listScripts(plug_mgr, scripts, getHackPath() + "scripts/", all);
|
|
|
|
listAllScripts(scripts, all);
|
|
|
|
if (!scripts.empty())
|
|
|
|
if (!scripts.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
con.print("\nscripts:\n");
|
|
|
|
con.print("\nscripts:\n");
|
|
|
|