//----------------------------------------------------------------------------- // Purpose: Loads additional commandline arguments from a config file for an app. // Filesystem must be initialized before calling this function. // keyname: Name of the block containing the key/args pairs (ie map or model name) // appname: Keyname for the commandline arguments to be loaded - typically the exe name. //----------------------------------------------------------------------------- void LoadCmdLineFromFile( int &argc, char **&argv, const char *keyname, const char *appname ) { sFoundConfigArgs = false; assert( g_pFileSystem ); if( !g_pFileSystem ) return; // Load the cfg file, and find the keyname KeyValues *kv = new KeyValues( "CommandLine" ); char filename[512]; Q_snprintf( filename, sizeof( filename ), "%s/cfg/commandline.cfg", gamedir ); if ( kv->LoadFromFile( g_pFileSystem, filename ) ) { // Load the commandline arguments for this app KeyValues *appKey = kv->FindKey( keyname ); if( appKey ) { const char *str = appKey->GetString( appname ); Msg( "Command Line found: %s\n", str ); AddArguments( argc, argv, str ); } } kv->deleteThis(); }
void CommandLine::ParseFromArgv(const ArgList& argv) { if (argv.empty()) { return; } // Anyway, we start from scratch. argv_ = Argv(1); last_not_param_ = argv_.begin(); switches_.clear(); SetProgram(FilePath(argv[0])); AddArguments(this, argv); }