{"record":{"id":"3c44d74921639b94","repo":"languagetool-org/languagetool","slug":"wrongparameternumberexception","errorCode":null,"errorMessage":"WrongParameterNumberException","messagePattern":"WrongParameterNumberException","errorType":"exception","errorClass":"WrongParameterNumberException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java","lineNumber":36,"sourceCode":" */\npackage org.languagetool.commandline;\n\nimport org.languagetool.JLanguageTool;\nimport org.languagetool.Language;\nimport org.languagetool.Languages;\n\nimport java.io.File;\nimport java.io.PrintStream;\nimport java.util.Arrays;\n\n/**\n * Parser for the command line arguments.\n */\nclass CommandLineParser {\n\n  CommandLineOptions parseOptions(String[] args) {\n    if (args.length < 1 || args.length > 14) {\n      throw new WrongParameterNumberException();\n    }\n    CommandLineOptions options = new CommandLineOptions();\n    for (int i = 0; i < args.length; i++) {\n      if (args[i].equals(\"--version\")) {\n        options.setPrintVersion(true);\n      } else if (args[i].equals(\"--list\")) {\n        options.setPrintLanguages(true);\n      } else if (args[i].equals(\"-h\") || args[i].equals(\"-help\") || args[i].equals(\"--help\") || args[i].equals(\"--?\")) {\n        options.setPrintUsage(true);\n      } else if (args[i].equals(\"-adl\") || args[i].equals(\"--autoDetect\")) {    // set autoDetect flag\n        options.setAutoDetect(true);\n      } else if (args[i].equals(\"-v\") || args[i].equals(\"--verbose\")) {\n        options.setVerbose(true);\n      } else if (args[i].equals(\"--line-by-line\")) {\n        options.setLineByLine(true);\n      } else if (args[i].equals(\"--enable-temp-off\")) {\n        options.setEnableTempOff(true);\n      } else if (args[i].equals(\"--clean-overlapping\")) {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java#L18-L54","documentation":"CommandLineParser.parseOptions() validates the raw argv array before parsing flags. It throws WrongParameterNumberException when the program is invoked with zero arguments or more than 14 arguments, because LanguageTool's command-line mode requires at least a text file (or text input) and only recognizes a bounded set of options.","triggerScenarios":"Running the `languagetool` launcher with no arguments at all (args.length == 0), or passing more than 14 arguments (e.g. many enabled/disabled rules combined with multiple flags pushing the count over the limit). Called from main() for every CLI invocation.","commonSituations":"New users running `java -cp ... org.languagetool.commandline.Main` without a file argument; CI scripts that lost their arguments due to quoting bugs; scripts accumulating many --disable/--enable rule lists until the 14-argument cap is exceeded.","solutions":["Pass at least one argument: the text file to check (e.g. `languagetool -l en mytext.txt`).","Count your arguments; consolidate rule lists into a single comma-separated value for -d/--disable or -e/--enable to stay at or below 14 arguments.","Show usage with --help (or see CommandLineParser.testUsage) to confirm the accepted argument forms.","If you need more options than the cap allows, use the JLanguageTool Java API or the HTTP server instead of the CLI."],"exampleFix":"// before\nlanguagetool\n// after\nlanguagetool -l en myfile.txt","handlingStrategy":"validation","validationCode":"if (args.length < 1 || args.length > 14) {\n  System.err.println(\"Expected 1-14 arguments, got \" + args.length + \". See --help.\");\n  System.exit(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  CommandLineOptions opts = new CommandLineParser().parseOptions(args);\n} catch (WrongParameterNumberException e) {\n  System.err.println(\"Invalid argument count; pass the text file and at most 14 arguments. Use --help.\");\n}","preventionTips":["Always pass the text file path explicitly in scripts.","Quote arguments so shell splitting does not drop or duplicate them.","Keep rule lists as single comma-separated values to limit argument count.","Prefer the JLanguageTool API or HTTP server for complex option sets."],"tags":["cli","argument-count","java"],"backgroundTag":"invalid-cli-argument","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}