Updates the plugin skeletons again

develop
Josh Cooper 2021-08-05 09:38:28 -07:00 committed by Myk
parent 79e2188a5f
commit 4aac87a7f0
2 changed files with 39 additions and 18 deletions

@ -47,7 +47,7 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector<PluginC
"~54 character description of plugin", //to use one line in the ``[DFHack]# ls`` output "~54 character description of plugin", //to use one line in the ``[DFHack]# ls`` output
command_callback1, command_callback1,
false, false,
"" "example usage"
" skeleton <option> <args>\n" " skeleton <option> <args>\n"
" explanation of plugin/command\n" " explanation of plugin/command\n"
"\n" "\n"

@ -1,37 +1,58 @@
#include "Console.h"
#include "Core.h" #include "Core.h"
#include "DataDefs.h" #include <Console.h>
#include "Export.h" #include <Export.h>
#include "PluginManager.h" #include <PluginManager.h>
#include <modules/EventManager.h>
//#include "df/world.h" //#include "df/world.h"
using namespace DFHack; using namespace DFHack;
using namespace df::enums;
DFHACK_PLUGIN("skeleton2"); DFHACK_PLUGIN("skeleton2");
DFHACK_PLUGIN_IS_ENABLED(enabled);
//REQUIRE_GLOBAL(world); //REQUIRE_GLOBAL(world);
command_result skeleton2 (color_ostream &out, std::vector <std::string> & parameters); command_result skeleton2 (color_ostream &out, std::vector <std::string> & parameters);
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands) {
{ commands.push_back(PluginCommand("skeleton2",
commands.push_back(PluginCommand( "~54 character description of plugin", //to use one line in the ``[DFHack]# ls`` output
"skeleton2", skeleton2,
"shortHelpString", false,
skeleton2, "example usage"
false, //allow non-interactive use " skeleton2 <option> <args>\n"
"longHelpString" " explanation of plugin/command\n"
)); "\n"
" skeleton2\n"
" what happens when using the command\n"
"\n"
" skeleton2 option1\n"
" what happens when using the command with option1\n"
"\n"));
return CR_OK; return CR_OK;
} }
DFhackCExport command_result plugin_shutdown (color_ostream &out) DFhackCExport command_result plugin_shutdown (color_ostream &out) {
{
return CR_OK; return CR_OK;
} }
command_result skeleton2 (color_ostream &out, std::vector <std::string> & parameters) DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
{ namespace EM = EventManager;
if (enable && !enabled) {
//using namespace EM::EventType;
//EM::EventHandler eventHandler(onNewEvent, maxTickFreq);
//EM::registerListener(EventType::JOB_COMPLETED, eventHandler, plugin_self);
//out.print("plugin enabled!\n");
} else if (!enable && enabled) {
EM::unregisterAll(plugin_self);
//out.print("plugin disabled!\n");
}
enabled = enable;
return CR_OK;
}
command_result skeleton2 (color_ostream &out, std::vector <std::string> & parameters) {
if (!parameters.empty()) if (!parameters.empty())
return CR_WRONG_USAGE; return CR_WRONG_USAGE;
CoreSuspender suspend; CoreSuspender suspend;