MCPcopy Create free account
hub / github.com/DFHack/dfhack / ls_helper

Function ls_helper

library/Core.cpp:675–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673}
674
675static void ls_helper(color_ostream &con, const std::span<const std::string> params) {
676 std::vector<std::string> filter;
677 bool skip_tags = false;
678 bool show_dev_commands = false;
679 std::string_view exclude_strs;
680
681 bool in_exclude = false;
682 for (const auto& str : params) {
683 if (in_exclude)
684 exclude_strs = str;
685 else if (str == "--notags")
686 skip_tags = true;
687 else if (str == "--dev")
688 show_dev_commands = true;
689 else if (str == "--exclude")
690 in_exclude = true;
691 else
692 filter.push_back(str);
693 }
694
695 ConditionalCoreSuspender suspend{};
696
697 if (!suspend) {
698 con.printerr("Failed Lua call to helpdb.help (could not acquire core lock).\n");
699 return;
700 }
701
702 auto L = DFHack::Core::getInstance().getLuaState();
703 Lua::StackUnwinder top(L);
704
705 if (!lua_checkstack(L, 5) ||
706 !Lua::PushModulePublic(con, L, "helpdb", "ls")) {
707 con.printerr("Failed to load helpdb Lua code\n");
708 return;
709 }
710
711 Lua::PushVector(L, filter);
712 Lua::Push(L, skip_tags);
713 Lua::Push(L, show_dev_commands);
714 Lua::Push(L, exclude_strs);
715
716 if (!Lua::SafeCall(con, L, 4, 0)) {
717 con.printerr("Failed Lua call to helpdb.ls.\n");
718 }
719}
720
721command_result Core::runCommand(color_ostream &con, const std::string &first_, std::vector<std::string> &parts, bool no_autocomplete)
722{

Callers 1

runCommandMethod · 0.85

Calls 5

lua_checkstackFunction · 0.85
PushModulePublicFunction · 0.85
PushVectorFunction · 0.85
PushFunction · 0.85
SafeCallFunction · 0.85

Tested by

no test coverage detected