{"record":{"id":"1bd60b5131dc3b0b","repo":"apache/maven","slug":"failed-to-parse-command-line-options-message","errorCode":null,"errorMessage":"Failed to parse command line options: ${message}","messagePattern":"Failed to parse command line options: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/EncryptParser.java","lineNumber":31,"sourceCode":" * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\npackage org.apache.maven.cling.invoker.mvnenc;\n\nimport org.apache.commons.cli.ParseException;\nimport org.apache.maven.api.cli.Options;\nimport org.apache.maven.cling.invoker.BaseParser;\n\npublic class EncryptParser extends BaseParser {\n    @Override\n    protected Options parseCliOptions(LocalContext context) {\n        try {\n            return CommonsCliEncryptOptions.parse(context.parserRequest.args().toArray(new String[0]));\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\"Failed to parse command line options: \" + e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":13,"sourceCodeEnd":35,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/EncryptParser.java#L13-L35","documentation":"The mvnenc sub-tool (EncryptParser) parses its own command line with CommonsCliEncryptOptions; a ParseException is rethrown as IllegalArgumentException 'Failed to parse command line options' with the reason appended. Only the options given to the encryption tool are involved, not general mvn build options.","triggerScenarios":"Passing an option the enc tool does not define (e.g. a build flag like -pl or -D), an unknown long option, or a value-taking option given without its value.","commonSituations":"Muscle memory applying mvn build flags to the sub-tool; wrapper scripts that append global options to every Maven-family invocation; commands copied from documentation of a different Maven version.","solutions":["Run the tool with its help option to list accepted options for the installed version.","Fix or remove the offending token named in the message.","Supply values for options that require them.","Re-copy the invocation from the current Maven documentation."],"exampleFix":"# before: build-style flag unknown to the tool\nmvn enc -DskipTests\n\n# after: only options the tool defines (see its help output)\nmn enc --help  # then use the listed options","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    new EncryptParser().parseCliOptions(context);\n} catch (IllegalArgumentException e) {\n    // message includes the Commons CLI reason\n    showToolUsageAndExit(e.getMessage());\n}","preventionTips":["Filter build-style flags out of wrapper scripts before delegating to the enc tool.","Derive tool invocations from `--help` output of the installed version."],"tags":["maven","mvnenc","encryption","cli","argument-parsing"],"backgroundTag":"cli-argument-parsing-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}