languagetool-org/languagetool · error · IllegalArgumentException
You cannot apply suggestions when tagging only
Error message
You cannot apply suggestions when tagging only
What it means
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.
Source
Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:69
options.setLineByLine(true);
} else if (args[i].equals("--enable-temp-off")) {
options.setEnableTempOff(true);
} else if (args[i].equals("--clean-overlapping")) {
options.setCleanOverlapping(true);
} else if (args[i].equals("--level")) {
String level = args[++i];
try {
options.setLevel(JLanguageTool.Level.valueOf(level));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unknown level '" + level + "' - currently, only 'PICKY' is supported");
}
} else if (args[i].equals("-t") || args[i].equals("--taggeronly")) {
options.setTaggerOnly(true);
if (options.isListUnknown()) {
throw new IllegalArgumentException("You cannot list unknown words when tagging only");
}
if (options.isApplySuggestions()) {
throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
}
} else if (args[i].equals("-r") || args[i].equals("--recursive")) {
options.setRecursive(true);
} else if (args[i].equals("-b2") || args[i].equals("--bitext")) {
options.setBitext(true);
} else if (args[i].equals("-eo") || args[i].equals("--enabledonly")) {
if (options.getDisabledRules().size() > 0) {
throw new IllegalArgumentException("You cannot specify both disabled rules and enabledonly");
}
options.setUseEnabledOnly();
} else if (args[i].equals("-d") || args[i].equals("--disable")) {
if (options.isUseEnabledOnly()) {
throw new IllegalArgumentException("You cannot specify both disabled rules and enabledonly");
}
checkArguments("-d/--disable", i, args);
String rules = args[++i];
options.setDisabledRules(Arrays.asList(rules.split(",")));
} else if (args[i].equals("-e") || args[i].equals("--enable")) {View on GitHub (pinned to 2e990059ce)
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.
Example fix
// before languagetool -a -t -l en file.txt // after languagetool -a -l en file.txt
Defensive patterns
Strategy: validation
Validate before calling
List<String> a = Arrays.asList(args);
boolean tagOnly = a.contains("-t") || a.contains("--taggeronly");
boolean apply = a.contains("-a") || a.contains("--apply");
if (tagOnly && apply) throw new IllegalArgumentException("-t and -a are mutually exclusive"); Try / catch
try {
new CommandLineParser().parseOptions(args);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("apply suggestions when tagging only")) {
System.err.println("Choose either -a/--apply or -t/--taggeronly, not both.");
}
} Prevention
- 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.
When it happens
Trigger: `languagetool -a -t file.txt` — --apply parsed first, then --taggeronly sees options.isApplySuggestions() == true.
Common situations: Users wanting both automatic fixes and fast tag-only runs; scripts appending flags from different profiles.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- You cannot list unknown words when tagging only
- You cannot specify both disabled rules and enabledonly
- JSON output format makes no sense for automatic application
- JSON output format is not implemented for "line by line" ana
- JSON output format is not implemented for Bitext
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/9100efd68273f1c1.
Report an issue: GitHub.