#ifndef COMMAND_REGISTRY_HPP #define COMMAND_REGISTRY_HPP #include #include #include #include #include #include #include namespace dropshell { struct CommandContext { std::string exename; std::string command; std::vector args; // Add more fields as needed (e.g., config pointer, output stream, etc.) }; struct CommandInfo { std::vector names; std::function handler; std::function autocomplete; // optional bool hidden = false; bool requires_config = true; bool requires_install = true; int min_args = 0; int max_args = -1; // -1 = unlimited std::string help_usage; // install SERVER [SERVICE] std::string help_description; // Install/reinstall/update service(s). Safe/non-destructive. std::string full_help; // detailed help for the command }; class CommandRegistry { public: static CommandRegistry& instance(); void register_command(const CommandInfo& info); // Returns nullptr if not found const CommandInfo* find_command(const std::string& name) const; // List all commands (optionally including hidden) std::vector list_commands(bool include_hidden = false) const; std::vector list_primary_commands(bool include_hidden = false) const; // For autocomplete void autocomplete(const CommandContext& ctx) const; private: CommandRegistry() = default; std::map> command_map_; std::vector> all_commands_; }; } // namespace dropshell #endif // COMMAND_REGISTRY_HPP