summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-08 02:24:24 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-08 02:24:24 +0300
commitdcd0d2e4d8a827d06a10344855d8d044bd26630d (patch)
treed80a5c0f9e9ef9025b42ed7a619fbf21f4a867d7
parent466b8491acd56454d82ab70d3fcbc06206b18e6a (diff)
downloadmv-dcd0d2e4d8a827d06a10344855d8d044bd26630d.tar.gz
mv-dcd0d2e4d8a827d06a10344855d8d044bd26630d.tar.bz2
mv-dcd0d2e4d8a827d06a10344855d8d044bd26630d.tar.xz
mv-dcd0d2e4d8a827d06a10344855d8d044bd26630d.zip
Add chat command for execute external programs.
New chat command: /execute NAME[ PAR] NAME - program name PAR - parameter
-rw-r--r--src/commands.cpp17
-rw-r--r--src/commands.h2
-rw-r--r--src/gui/chatwindow.cpp1
3 files changed, 20 insertions, 0 deletions
diff --git a/src/commands.cpp b/src/commands.cpp
index dce8c57e0..abd30f713 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1056,6 +1056,23 @@ impHandler1(open)
openBrowser(url);
}
+impHandler1(execute)
+{
+ const size_t idx = args.find(" ");
+ std::string name;
+ std::string params;
+ if (idx == std::string::npos)
+ {
+ name = args;
+ }
+ else
+ {
+ name = args.substr(0, idx);
+ params = args.substr(idx + 1);
+ }
+ execFile(name, name, params, "");
+}
+
#ifdef DEBUG_DUMP_LEAKS1
void showRes(std::string str, ResourceManager::Resources *res);
diff --git a/src/commands.h b/src/commands.h
index b0e3b6951..7d1cf80e1 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -113,6 +113,7 @@ namespace Commands
decHandler(dumpTests);
decHandler(dumpOGL);
decHandler(cacheInfo);
+ decHandler(execute);
void replaceVars(std::string &str);
}
@@ -190,6 +191,7 @@ static const CommandInfo commands[] =
{"dumpogl", &Commands::dumpOGL},
{"url", &Commands::url},
{"open", &Commands::open},
+ {"execute", &Commands::execute},
{"hack", &Commands::hack}
};
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 59da87d37..9d8739ddb 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -295,6 +295,7 @@ void ChatWindow::fillCommands()
mCommands.push_back("/close");
mCommands.push_back("/cacheinfo");
mCommands.push_back("/erase ");
+ mCommands.push_back("/execute ");
mCommands.push_back("/follow ");
mCommands.push_back("/heal ");
mCommands.push_back("/ignoreall");