Nuria::ArgumentManager::ArgumentManager (QObject *parent) : QObject (parent) { // g_data = new Nuria::ArgumentManagerPrivate; // QStringList args = qApp->arguments (); QString configPath = qApp->applicationDirPath () + "/settings.cfg"; // Has the user passed a different path to the settings file? for (int i = 1; i < args.length (); i++) { const QString &cur = args.at (i); if (cur.startsWith (QLatin1String ("nuria.settings="), Qt::CaseInsensitive)) { configPath = cur.mid (cur.indexOf ('=') + 1); break; } } // Load additional settings from settings.cfg QFile config (configPath); if (config.open (QIODevice::ReadOnly | QIODevice::Text)) { while (!config.atEnd ()) { QString line = config.readLine (); if (line.indexOf ('#') != -1) line = line.left (line.indexOf ('#')); else if (line.endsWith (QLatin1Char ('\n'))) line.chop (1); else if (line.endsWith (QLatin1String ("\r\n"))) line.chop (2); if (!line.isEmpty ()) matchArgument (line); } } // Parse command line arguments for (int i = 1; i < args.length (); i++) matchArgument (args.at (i)); }
//============================================================================== int performCommandLine (const String& commandLine) { StringArray args; args.addTokens (commandLine, true); args.trim(); String command (args[0]); if (matchArgument (command, "help")) return showHelp(); if (matchArgument (command, "h")) return showHelp(); if (matchArgument (command, "resave")) return resaveProject (args, false); if (matchArgument (command, "resave-resources")) return resaveProject (args, true); if (matchArgument (command, "set-version")) return setVersion (args); if (matchArgument (command, "bump-version")) return bumpVersion (args); if (matchArgument (command, "git-tag-version")) return gitTag (args); if (matchArgument (command, "buildmodule")) return buildModules (args, false); if (matchArgument (command, "buildallmodules")) return buildModules (args, true); if (matchArgument (command, "status")) return showStatus (args); return commandLineNotPerformed; }
//============================================================================== int performCommandLine (const String& commandLine) { StringArray args; args.addTokens (commandLine, true); args.trim(); if (matchArgument (args[0], "help")) return showHelp(); if (matchArgument (args[0], "resave")) return resaveProject (args, false); if (matchArgument (args[0], "resave-resources")) return resaveProject (args, true); if (matchArgument (args[0], "buildmodule")) return buildModules (args, false); if (matchArgument (args[0], "buildallmodules")) return buildModules (args, true); if (matchArgument (args[0], "listmodules")) return listModules(); if (matchArgument (args[0], "status")) return showStatus (args); return commandLineNotPerformed; }
//============================================================================== int performCommandLine (const String& commandLine) { StringArray args; args.addTokens (commandLine, true); args.trim(); String command (args[0]); try { if (matchArgument (command, "help")) { showHelp(); return 0; } if (matchArgument (command, "h")) { showHelp(); return 0; } if (matchArgument (command, "resave")) { resaveProject (args, false); return 0; } if (matchArgument (command, "resave-resources")) { resaveProject (args, true); return 0; } if (matchArgument (command, "set-version")) { setVersion (args); return 0; } if (matchArgument (command, "bump-version")) { bumpVersion (args); return 0; } if (matchArgument (command, "git-tag-version")) { gitTag (args); return 0; } if (matchArgument (command, "buildmodule")) { buildModules (args, false); return 0; } if (matchArgument (command, "buildallmodules")) { buildModules (args, true); return 0; } if (matchArgument (command, "status")) { showStatus (args); return 0; } if (matchArgument (command, "trim-whitespace")) { cleanWhitespace (args, false); return 0; } if (matchArgument (command, "remove-tabs")) { cleanWhitespace (args, true); return 0; } if (matchArgument (command, "tidy-divider-comments")) { tidyDividerComments (args); return 0; } if (matchArgument (command, "fix-broken-include-paths")) { fixRelativeIncludePaths (args); return 0; } } catch (const CommandLineError& error) { std::cout << error.message << std::endl << std::endl; return 1; } return commandLineNotPerformed; }
//============================================================================== int performCommandLine (const String& commandLine) { StringArray args; args.addTokens (commandLine, true); args.trim(); String command (args[0]); try { if (matchArgument (command, "help")) { showHelp(); return 0; } if (matchArgument (command, "h")) { showHelp(); return 0; } if (matchArgument (command, "resave")) { resaveProject (args, false); return 0; } if (matchArgument (command, "resave-resources")) { resaveProject (args, true); return 0; } if (matchArgument (command, "get-version")) { getVersion (args); return 0; } if (matchArgument (command, "set-version")) { setVersion (args); return 0; } if (matchArgument (command, "bump-version")) { bumpVersion (args); return 0; } if (matchArgument (command, "git-tag-version")) { gitTag (args); return 0; } if (matchArgument (command, "buildmodule")) { buildModules (args, false); return 0; } if (matchArgument (command, "buildallmodules")) { buildModules (args, true); return 0; } if (matchArgument (command, "status")) { showStatus (args); return 0; } if (matchArgument (command, "trim-whitespace")) { cleanWhitespace (args, false); return 0; } if (matchArgument (command, "remove-tabs")) { cleanWhitespace (args, true); return 0; } if (matchArgument (command, "tidy-divider-comments")) { tidyDividerComments (args); return 0; } if (matchArgument (command, "fix-broken-include-paths")) { fixRelativeIncludePaths (args); return 0; } if (matchArgument (command, "obfuscated-string-code")) { generateObfuscatedStringCode (args); return 0; } if (matchArgument (command, "encode-binary")) { encodeBinary (args); return 0; } if (matchArgument (command, "trans")) { scanFoldersForTranslationFiles (args); return 0; } if (matchArgument (command, "trans-finish")) { createFinishedTranslationFile (args); return 0; } if (matchArgument (command, "set-global-search-path")) { setGlobalPath (args); return 0; } if (matchArgument (command, "create-project-from-pip")) { createProjectFromPIP (args); return 0; } } catch (const CommandLineError& error) { std::cout << error.message << std::endl << std::endl; return 1; } return commandLineNotPerformed; }