{"record":{"id":"9100efd68273f1c1","repo":"languagetool-org/languagetool","slug":"you-cannot-apply-suggestions-when-tagging-only","errorCode":null,"errorMessage":"You cannot apply suggestions when tagging only","messagePattern":"You cannot apply suggestions when tagging only","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java","lineNumber":69,"sourceCode":"        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);\n        String rules = args[++i];\n        options.setDisabledRules(Arrays.asList(rules.split(\",\")));\n      } else if (args[i].equals(\"-e\") || args[i].equals(\"--enable\")) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java#L51-L87","documentation":"parseOptions() rejects combining `-t/--taggeronly` with `-a/--apply` (applySuggestions). When --taggeronly is parsed and applySuggestions was already enabled, it throws this IllegalArgumentException: tagging alone cannot rewrite the text with correction suggestions.","triggerScenarios":"`languagetool -a -t file.txt` — --apply parsed first, then --taggeronly sees options.isApplySuggestions() == true.","commonSituations":"Users wanting both automatic fixes and fast tag-only runs; scripts appending flags from different profiles.","solutions":["Drop -t/--taggeronly to allow applying suggestions.","Drop -a/--apply if tag-only output is what you need.","Run two invocations: one to tag, one to apply."],"exampleFix":"// before\nlanguagetool -a -t -l en file.txt\n// after\nlanguagetool -a -l en file.txt","handlingStrategy":"validation","validationCode":"List<String> a = Arrays.asList(args);\nboolean tagOnly = a.contains(\"-t\") || a.contains(\"--taggeronly\");\nboolean apply = a.contains(\"-a\") || a.contains(\"--apply\");\nif (tagOnly && apply) throw new IllegalArgumentException(\"-t and -a are mutually exclusive\");","typeGuard":null,"tryCatchPattern":"try {\n  new CommandLineParser().parseOptions(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"apply suggestions when tagging only\")) {\n    System.err.println(\"Choose either -a/--apply or -t/--taggeronly, not both.\");\n  }\n}","preventionTips":["Treat -t as incompatible with any text-modifying flag.","Document flag profiles in scripts rather than merging ad-hoc flags.","Check options state before invoking the CLI."],"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"}