| 673 | } |
| 674 | |
| 675 | static 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 | |
| 721 | command_result Core::runCommand(color_ostream &con, const std::string &first_, std::vector<std::string> &parts, bool no_autocomplete) |
| 722 | { |
no test coverage detected