Skip to content

Commit

Permalink
i18n and modernize installPackage, uninstallPackage (Mudlet#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadi2 authored Dec 31, 2017
1 parent 4029df3 commit e8bb139
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/TLuaInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10241,33 +10241,29 @@ int TLuaInterpreter::getCmdLine(lua_State* L)

int TLuaInterpreter::installPackage(lua_State* L)
{
string event;
QString location;
if (!lua_isstring(L, 1)) {
lua_pushstring(L, "installPackage(): wrong argument type");
lua_error(L);
return 1;
lua_pushfstring(L, "installPackage: bad argument #1 (package location path and file name as string expected, got %s)", luaL_typename(L, 1));
return lua_error(L);
} else {
event = lua_tostring(L, 1);
location = QString::fromUtf8(lua_tostring(L, 1));
}
Host& host = getHostFromLua(L);
QString package = event.c_str();
host.installPackage(package, 0);
host.installPackage(location, 0);
return 0;
}

int TLuaInterpreter::uninstallPackage(lua_State* L)
{
string event;
QString packageName;
if (!lua_isstring(L, 1)) {
lua_pushstring(L, "uninstallPackage(): wrong argument type");
lua_error(L);
return 1;
lua_pushfstring(L, "uninstallPackage: bad argument #1 (package name as string expected, got %s)", luaL_typename(L, 1));
return lua_error(L);
} else {
event = lua_tostring(L, 1);
packageName = QString::fromUtf8(lua_tostring(L, 1));
}
Host& host = getHostFromLua(L);
QString package = event.c_str();
host.uninstallPackage(package, 0);
host.uninstallPackage(packageName, 0);
return 0;
}

Expand Down

0 comments on commit e8bb139

Please sign in to comment.