{"record":{"id":"9518eee8e91d0c6d","repo":"languagetool-org/languagetool","slug":"unknown-parameter-arg","errorCode":null,"errorMessage":"Unknown parameter: <arg>","messagePattern":"Unknown parameter: <arg>","errorType":"validation","errorClass":"UnknownParameterException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java","lineNumber":174,"sourceCode":"          throw new IllegalArgumentException(\"JSON output format makes no sense for automatic application of suggestions\");\n        }\n      } else if (args[i].equals(\"-p\") || args[i].equals(\"--profile\")) {\n        options.setProfile(true);\n        if (options.isJsonFormat()) {\n          throw new IllegalArgumentException(\"JSON output format makes no sense for profiling\");\n        }\n        if (options.isApplySuggestions()) {\n          throw new IllegalArgumentException(\"Applying suggestions makes no sense for profiling\");\n        }\n        if (options.isTaggerOnly()) {\n          throw new IllegalArgumentException(\"Tagging makes no sense for profiling\");\n        }\n      } else if (args[i].equals(\"--xmlfilter\")) {\n        options.setXmlFiltering(true);\n      } else if (i == args.length - 1) {\n        options.setFilename(args[i]);\n      } else {\n        throw new UnknownParameterException(\"Unknown parameter: \" + args[i]);\n      }\n    }\n    return options;\n  }\n\n  void printUsage() {\n    printUsage(System.out);\n  }\n\n  void printUsage(PrintStream stream) {\n    stream.println(\"Usage: java -jar languagetool-commandline.jar [OPTION]... FILE\\n\"\n            + \" FILE                      plain text file to be checked\\n\"\n            + \" Available options:\\n\"\n            + \"  -r, --recursive          work recursively on directory, not on a single file\\n\"\n            + \"  -c, --encoding ENC       character set of the input text, e.g. utf-8 or latin1\\n\"\n            + \"  -b                       assume that a single line break marks the end of a paragraph\\n\"\n            + \"  -l, --language LANG      the language code of the text, e.g. en for English, en-GB for British English\\n\"\n            + \"  --list                   print all available languages and exit\\n\"","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java#L156-L192","documentation":"CommandLineParser iterates all args and every unrecognized token that is not the final filename is rejected with UnknownParameterException ('Unknown parameter: <arg>'). UnknownParameterException extends IllegalArgumentException, signaling a typo'd or unsupported CLI option.","triggerScenarios":"Passing any flag not handled by parseOptions' if/else chain (e.g. `--spellcheck`, `-x`, or a misspelling like `--langauge en`) in a position that is not the last argument; also passing two filenames (the second one lands here).","commonSituations":"Typos in long option names; copying options from an older or newer LanguageTool version where the flag was renamed; passing options after the filename; accidentally passing two files to a tool that accepts one.","solutions":["Run `languagetool --help` (or inspect printUsage) and use an exact supported flag name","Check flag spelling and single-vs-double dash form","Put the input filename last; options after it will be treated as unknown parameters","Verify the option exists in your installed LanguageTool version"],"exampleFix":"// before\nlanguagetool -l en --langauge en file.txt\n// after\nlanguagetool -l en file.txt","handlingStrategy":"validation","validationCode":"for (int i = 0; i < args.length - 1; i++) {\n  if (!KNOWN_OPTIONS.contains(args[i])) {\n    throw new IllegalArgumentException(\"Unknown parameter: \" + args[i]);\n  }\n}","typeGuard":"static final Set<String> KNOWN_OPTIONS = Set.of(\"-l\",\"--language\",\"-c\",\"--encoding\",\"-t\",\"--tagger-only\",\"-a\",\"--apply-suggestions\",\"-p\",\"--profile\",\"-u\",\"--list-unknown\",\"-r\",\"--recursive\",\"-b\",\"--bitext\",\"--twolines\",\"--xmlfilter\",\"--level\",\"--disable\",\"--enable\",\"--version\",\"--help\");","tryCatchPattern":"try {\n  options = CommandLineParser.parseOptions(args);\n} catch (UnknownParameterException e) {\n  System.err.println(e.getMessage() + \" — run 'languagetool --help' for valid options\");\n  System.exit(2);\n}","preventionTips":["Always verify option names with --help for your installed version","Put the input filename last; all preceding tokens must be known options","Watch for renamed flags between LanguageTool versions","Quote variables so a split value does not become a bogus option"],"tags":["cli","commandline","unknown-option","argument-parsing"],"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-14T05:17:10.506Z"}