MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ParseCommandLine

Method ParseCommandLine

engine/Poseidon/Foundation/Platform/AppConfig.cpp:233–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231
232AppConfig::AppConfig() {}
233
234void 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;

Callers

nothing calls this directly

Calls 15

NormalizeLegacyArgumentsFunction · 0.85
ContainsCliArgFunction · 0.85
DetectHelpModeFunction · 0.85
DetectAppRoleFunction · 0.85
IsVisibleInHelpFunction · 0.85
ResolveCliManagedModsDirFunction · 0.85
ResolveModPathListFunction · 0.85
WriteCliTextFunction · 0.85
reserveMethod · 0.80
sizeMethod · 0.80
OkMethod · 0.80
RStringClass · 0.50

Tested by

no test coverage detected