| 40 | } |
| 41 | |
| 42 | int main(int argc, char* argv[]) |
| 43 | { |
| 44 | bool include_builtin = false; |
| 45 | std::vector<std::string> plugins; |
| 46 | |
| 47 | // Parse command line arguments |
| 48 | for(int i = 1; i < argc; ++i) |
| 49 | { |
| 50 | if(std::strcmp(argv[i], "--include-builtin") == 0) |
| 51 | { |
| 52 | include_builtin = true; |
| 53 | } |
| 54 | else if(std::strcmp(argv[i], "--plugin") == 0) |
| 55 | { |
| 56 | if(i + 1 >= argc) |
| 57 | { |
| 58 | std::fprintf(stderr, "Error: --plugin requires a path argument\n"); |
| 59 | return 1; |
| 60 | } |
| 61 | plugins.push_back(argv[++i]); |
| 62 | } |
| 63 | else if(std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) |
| 64 | { |
| 65 | printUsage(argv[0]); |
| 66 | return 0; |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | std::fprintf(stderr, "Error: Unknown option '%s'\n", argv[i]); |
| 71 | printUsage(argv[0]); |
| 72 | return 1; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | BT::BehaviorTreeFactory factory; |
| 77 | |
| 78 | // Load plugins |
| 79 | for(const auto& plugin_path : plugins) |
| 80 | { |
| 81 | try |
| 82 | { |
| 83 | factory.registerFromPlugin(plugin_path); |
| 84 | } |
| 85 | catch(const std::exception& e) |
| 86 | { |
| 87 | std::fprintf(stderr, "Error loading plugin '%s': %s\n", plugin_path.c_str(), |
| 88 | e.what()); |
| 89 | return 1; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // Generate and print the TreeNodesModel XML |
| 94 | std::string xml = BT::writeTreeNodesModelXML(factory, include_builtin); |
| 95 | std::cout << xml << std::endl; |
| 96 | |
| 97 | return 0; |
| 98 | } |
nothing calls this directly
no test coverage detected