{"record":{"id":"4c9fa202eaad17fd","repo":"languagetool-org/languagetool","slug":"you-cannot-list-unknown-words-when-tagging-only","errorCode":null,"errorMessage":"You cannot list unknown words when tagging only","messagePattern":"You cannot list unknown words when tagging only","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java","lineNumber":66,"sourceCode":"      } 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\")) {\n        options.setCleanOverlapping(true);\n      } else if (args[i].equals(\"--level\")) {\n        String level = args[++i];\n        try {\n          options.setLevel(JLanguageTool.Level.valueOf(level));\n        } catch (IllegalArgumentException e) {\n          throw new IllegalArgumentException(\"Unknown level '\" + level + \"' - currently, only 'PICKY' is supported\");\n        }\n      } else if (args[i].equals(\"-t\") || args[i].equals(\"--taggeronly\")) {\n        options.setTaggerOnly(true);\n        if (options.isListUnknown()) {\n          throw new IllegalArgumentException(\"You cannot list unknown words when tagging only\");\n        }\n        if (options.isApplySuggestions()) {\n          throw new IllegalArgumentException(\"You cannot apply suggestions when tagging only\");\n        }\n      } else if (args[i].equals(\"-r\") || args[i].equals(\"--recursive\")) {\n        options.setRecursive(true);\n      } else if (args[i].equals(\"-b2\") || args[i].equals(\"--bitext\")) {\n        options.setBitext(true);\n      } else if (args[i].equals(\"-eo\") || args[i].equals(\"--enabledonly\")) {\n        if (options.getDisabledRules().size() > 0) {\n          throw new IllegalArgumentException(\"You cannot specify both disabled rules and enabledonly\");\n        }\n        options.setUseEnabledOnly();\n      } else if (args[i].equals(\"-d\") || args[i].equals(\"--disable\")) {\n        if (options.isUseEnabledOnly()) {\n          throw new IllegalArgumentException(\"You cannot specify both disabled rules and enabledonly\");\n        }\n        checkArguments(\"-d/--disable\", i, args);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java#L48-L84","documentation":"parseOptions() enforces flag exclusivity: `-u/--list-unknown` cannot be combined with `-t/--taggeronly`. When --taggeronly is parsed and list-unknown was already set (options.isListUnknown()), it throws IllegalArgumentException. Tag-only mode just tags text and does not run the spell checker that produces unknown-word lists, so the combination is rejected.","triggerScenarios":"`languagetool -t -u file.txt` (or the long forms --taggeronly --list-unknown) with -u appearing before -t on the command line.","commonSituations":"Script merging two previous invocations' flags; users assuming the flags are independent; documentation examples concatenated.","solutions":["Remove -u/--list-unknown if you want tagger-only mode.","Remove -t/--taggeronly if you want the unknown-words list.","Run two separate invocations if you need both behaviors."],"exampleFix":"// before\nlanguagetool -t -u -l en file.txt\n// after\nlanguagetool -t -l en file.txt","handlingStrategy":"validation","validationCode":"boolean hasTaggerOnly = Arrays.asList(args).contains(\"-t\") || Arrays.asList(args).contains(\"--taggeronly\");\nboolean hasListUnknown = Arrays.asList(args).contains(\"-u\") || Arrays.asList(args).contains(\"--list-unknown\");\nif (hasTaggerOnly && hasListUnknown) throw new IllegalArgumentException(\"-t and -u are mutually exclusive\");","typeGuard":null,"tryCatchPattern":"try {\n  new CommandLineParser().parseOptions(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"list unknown words when tagging only\")) {\n    System.err.println(\"Remove either -t/--taggeronly or -u/--list-unknown.\");\n  }\n}","preventionTips":["Never combine -t and -u in generated command lines.","Keep flags in one place in wrapper scripts so exclusivity is visible.","Test generated argument lists before production use."],"tags":["cli","conflicting-flags"],"backgroundTag":"mutually-exclusive-flags","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"}