| 149 | } |
| 150 | |
| 151 | static void PrintHelpFor(const CommandLineCommand* commands) |
| 152 | { |
| 153 | // Print usage |
| 154 | const char* usageString = "usage: openrct2 "; |
| 155 | const size_t usageStringLength = String::lengthOf(usageString); |
| 156 | Console::Write(usageString); |
| 157 | |
| 158 | // Get the largest command name length and parameter length |
| 159 | size_t maxNameLength = 0; |
| 160 | size_t maxParamsLength = 0; |
| 161 | const CommandLineCommand* command; |
| 162 | for (command = commands; command->Name != nullptr; command++) |
| 163 | { |
| 164 | maxNameLength = std::max(maxNameLength, String::lengthOf(command->Name)); |
| 165 | maxParamsLength = std::max(maxParamsLength, String::lengthOf(command->Parameters)); |
| 166 | } |
| 167 | |
| 168 | for (command = commands; command->Name != nullptr; command++) |
| 169 | { |
| 170 | if (command != commands) |
| 171 | { |
| 172 | Console::WriteSpace(usageStringLength); |
| 173 | } |
| 174 | |
| 175 | Console::Write(command->Name); |
| 176 | Console::WriteSpace(maxNameLength - String::lengthOf(command->Name) + 1); |
| 177 | |
| 178 | if (command->SubCommands == nullptr) |
| 179 | { |
| 180 | Console::Write(command->Parameters); |
| 181 | Console::WriteSpace(maxParamsLength - String::lengthOf(command->Parameters)); |
| 182 | |
| 183 | if (command->Options != nullptr) |
| 184 | { |
| 185 | Console::Write(" [options]"); |
| 186 | } |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | Console::Write("..."); |
| 191 | } |
| 192 | Console::WriteLine(); |
| 193 | } |
| 194 | Console::WriteLine(); |
| 195 | |
| 196 | if (commands->Options != nullptr) |
| 197 | { |
| 198 | PrintOptions(commands->Options); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | static void PrintOptions(const CommandLineOptionDefinition* options) |
| 203 | { |
no test coverage detected