| 85 | ******************************************************************************/ |
| 86 | |
| 87 | int CommandLineInterface::execute(const QStringList& args) noexcept { |
| 88 | QStringList positionalArgNames; |
| 89 | QMap<QString, QPair<QString, QString>> commands = { |
| 90 | {"open-project", |
| 91 | {tr("Open a project to execute project-related tasks."), |
| 92 | "open-project [command_options]"}}, // no tr()! |
| 93 | {"open-library", |
| 94 | {tr("Open a library to execute library-related tasks."), |
| 95 | "open-library [command_options]"}}, // no tr()! |
| 96 | {"open-symbol", |
| 97 | {tr("Open a symbol to execute symbol-related tasks."), |
| 98 | "open-symbol [command_options]"}}, // no tr()! |
| 99 | {"open-package", |
| 100 | {tr("Open a package to execute package-related tasks."), |
| 101 | "open-package [command_options]"}}, // no tr()! |
| 102 | {"open-step", |
| 103 | {tr("Open a STEP model to execute STEP-related tasks outside of a " |
| 104 | "library."), |
| 105 | "open-step [command_options]"}}, // no tr()! |
| 106 | }; |
| 107 | |
| 108 | // Add global options |
| 109 | QCommandLineParser parser; |
| 110 | parser.setApplicationDescription(tr("LibrePCB Command Line Interface")); |
| 111 | // Don't use the built-in addHelpOption() since it also adds the "--help-all" |
| 112 | // option which we don't need, and the OS-dependent option "-?". |
| 113 | const QCommandLineOption helpOption({"h", "help"}, tr("Print this message.")); |
| 114 | parser.addOption(helpOption); |
| 115 | const QCommandLineOption versionOption({"V", "version"}, |
| 116 | tr("Displays version information.")); |
| 117 | parser.addOption(versionOption); |
| 118 | QCommandLineOption verboseOption({"v", "verbose"}, tr("Verbose output.")); |
| 119 | parser.addOption(verboseOption); |
| 120 | parser.addPositionalArgument("command", |
| 121 | tr("The command to execute (see list below).")); |
| 122 | positionalArgNames.append("command"); |
| 123 | |
| 124 | // Define options for "open-project" |
| 125 | QCommandLineOption ercOption( |
| 126 | "erc", |
| 127 | tr("Run the electrical rule check, print all non-approved " |
| 128 | "warnings/errors and " |
| 129 | "report failure (exit code = 1) if there are non-approved messages.")); |
| 130 | QCommandLineOption drcOption( |
| 131 | "drc", |
| 132 | tr("Run the design rule check, print all non-approved warnings/errors " |
| 133 | "and report failure (exit code = 1) if there are non-approved " |
| 134 | "messages.")); |
| 135 | QCommandLineOption drcSettingsOption( |
| 136 | "drc-settings", |
| 137 | tr("Override DRC settings by providing a *.lp file containing custom " |
| 138 | "settings. If not set, the settings from the boards will be used " |
| 139 | "instead."), |
| 140 | tr("file")); |
| 141 | QCommandLineOption runSpecificJobOption( |
| 142 | "run-job", |
| 143 | tr("Run a particular output job. Can be given multiple times to run " |
| 144 | "multiple jobs."), |
no test coverage detected