| 231 | |
| 232 | AppConfig::AppConfig() {} |
| 233 | |
| 234 | void AppConfig::ParseCommandLine(int argc, char** argv) |
| 235 | { |
| 236 | if (_parsed) |
| 237 | { |
| 238 | return; |
| 239 | } |
| 240 | _parsed = true; |
| 241 | |
| 242 | // Console attachment is handled by entry points (WinMain / main) |
| 243 | // via attachParentConsole() before Application::Run() |
| 244 | |
| 245 | try |
| 246 | { |
| 247 | std::vector<std::string> normalizedArgs = NormalizeLegacyArguments(argc, argv); |
| 248 | if (BuildInfo::ReleaseBuild && ContainsCliArg(normalizedArgs, "--dev")) |
| 249 | { |
| 250 | _parseFatalError = "--dev is not supported in release builds"; |
| 251 | _parseFatalExitCode = 2; |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | const CliHelpMode helpMode = DetectHelpMode(normalizedArgs); |
| 256 | const CliAppRole appRole = DetectAppRole(normalizedArgs); |
| 257 | const bool serverRole = appRole == CliAppRole::Server; |
| 258 | const std::string versionForVersionFlag = |
| 259 | (const char*)Poseidon::GetVersionStringForState(ContainsCliArg(normalizedArgs, "--dev"), |
| 260 | GApp != nullptr && GApp->IsDemo()); |
| 261 | |
| 262 | CLI::App app{serverRole ? "Arma: Cold War Assault - Remastered Dedicated Server" |
| 263 | : "Arma: Cold War Assault - Remastered"}; |
| 264 | |
| 265 | // Disable default help flag so we can reuse -h for --height |
| 266 | app.set_help_flag("--help,--help-full", "Print help and exit"); |
| 267 | app.set_version_flag("--version", versionForVersionFlag); |
| 268 | if (serverRole) |
| 269 | app.usage("[OPTIONS]"); |
| 270 | if (BuildInfo::ReleaseBuild) |
| 271 | app.footer(serverRole ? "Use --help-full for advanced server options." |
| 272 | : "Use --help-full for advanced user options."); |
| 273 | else |
| 274 | app.footer( |
| 275 | serverRole |
| 276 | ? "Use --help-full for advanced server options. Use --help --dev for developer and test options." |
| 277 | : "Use --help-full for advanced user options. Use --help --dev for developer and test options."); |
| 278 | |
| 279 | app.allow_windows_style_options(); |
| 280 | |
| 281 | // Tolerate unknown options — app-specific CLI (e.g. PoseidonUITest's |
| 282 | // --start-display / --dump-ui / --record) parses the same argv after |
| 283 | // AppConfig and picks up what isn't recognized here. |
| 284 | app.allow_extras(); |
| 285 | |
| 286 | auto showGroup = [helpMode](CLI::App* group, CliHelpVisibility visibility, bool roleVisible = true) -> CLI::App* |
| 287 | { |
| 288 | if (!roleVisible || !IsVisibleInHelp(visibility, helpMode)) |
| 289 | group->group(""); |
| 290 | return group; |
nothing calls this directly
no test coverage detected