Skip to content

Commit

Permalink
Console|libdoomsday: Added the "ds" command for running Doomsday Script
Browse files Browse the repository at this point in the history
The arguments of "ds" are parsed and executed as Doomsday Script.
  • Loading branch information
skyjake committed Oct 16, 2017
1 parent b66a8a6 commit c4d6bb8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doomsday/apps/libdoomsday/src/console/exec.cpp
Expand Up @@ -39,6 +39,8 @@
#include <de/Log>
#include <de/LogBuffer>
#include <de/NativeFile>
#include <de/Process>
#include <de/Script>
#include <de/ScriptSystem>
#include <de/Time>
#include <de/TextValue>
Expand Down Expand Up @@ -106,6 +108,7 @@ D_CMD(Wait);
D_CMD(InspectMobj);
D_CMD(DebugCrash);
D_CMD(DebugError);
D_CMD(DoomsdayScript);

void initVariableBindings(Binder &);

Expand Down Expand Up @@ -142,6 +145,7 @@ void Con_Register(void)
#ifdef _DEBUG
C_CMD("crash", NULL, DebugCrash);
#endif
C_CMD("ds", "s*", DoomsdayScript);

Con_DataRegister();
}
Expand Down Expand Up @@ -1400,3 +1404,19 @@ D_CMD(ListAliases)
LOG_SCR_MSG("Found %i aliases") << numPrinted;
return true;
}

D_CMD(DoomsdayScript)
{
DENG_UNUSED(src);
DENG_UNUSED(argc);
String source;
for (int i = 1; i < argc; ++i)
{
if (source) source += " ";
source += String(argv[i]);
}
Script script(source);
Process proc(script);
proc.execute();
return true;
}
6 changes: 6 additions & 0 deletions doomsday/apps/libdoomsday/src/filesys/fs_main.cpp
Expand Up @@ -42,6 +42,7 @@
#include <de/LogBuffer>
#include <de/memory.h>
#include <de/findfile.h>
#include <de/FileSystem>

using namespace de;

Expand Down Expand Up @@ -1238,6 +1239,11 @@ D_CMD(ListFiles)
LOG_RES_MSG(_E(b)"Total: " _E(.) "%i files in %i packages")
<< totalFiles << totalPackages;

if (auto *svFiles = FS::get().tryLocate<Folder const>("/sys/server/files"))
{
LOG_RES_MSG("Server files:\n" _E(m) "%s") << svFiles->contentsAsText();
}

return true;
}

Expand Down

0 comments on commit c4d6bb8

Please sign in to comment.