{"record":{"id":"16e280ffee2c6e90","repo":"languagetool-org/languagetool","slug":"you-cannot-specify-both-disabled-rules-and-enabled","errorCode":null,"errorMessage":"You cannot specify both disabled rules and enabledonly","messagePattern":"You cannot specify both disabled rules and enabledonly","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java","lineNumber":77,"sourceCode":"          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\")) {\n        checkArguments(\"-e/--enable\", i, args);\n        String rules = args[++i];\n        options.setEnabledRules(Arrays.asList(rules.split(\",\")));\n      } else if (args[i].equals(\"--enablecategories\")) {\n        checkArguments(\"--enablecategories\", i, args);\n        String categories = args[++i];\n        options.setEnabledCategories(Arrays.asList(categories.split(\",\")));\n      } else if (args[i].equals(\"--disablecategories\")) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java#L59-L95","documentation":"`-eo/--enabledonly` restricts checking to explicitly enabled rules, so it is incompatible with -d/--disable. When --enabledonly is parsed and the disabled-rules list is non-empty, parseOptions() throws IllegalArgumentException.","triggerScenarios":"`languagetool -d GRAMMAR -eo -l en file.txt` — --disable parsed before --enabledonly with a non-empty disabled list.","commonSituations":"Users combining rule-selection flags without realizing the two are opposite selection modes; shell aliases appending -eo.","solutions":["Remove -eo/--enabledonly if you need to disable specific rules.","Remove the -d/--disable list if you truly want enabled-only mode.","Switch to -e/--enable with an explicit rule list instead of mixing selection modes."],"exampleFix":"// before\nlanguagetool -d UPPERCASE_SENTENCE_START -eo -l en file.txt\n// after\nlanguagetool -eo -l en file.txt","handlingStrategy":"validation","validationCode":"List<String> a = Arrays.asList(args);\nif ((a.contains(\"-eo\") || a.contains(\"--enabledonly\")) &&\n    (a.contains(\"-d\") || a.contains(\"--disable\"))) {\n  throw new IllegalArgumentException(\"-eo and -d cannot be combined\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  new CommandLineParser().parseOptions(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"disabled rules and enabledonly\")) {\n    System.err.println(\"Use either -eo/--enabledonly or -d/--disable, never both.\");\n  }\n}","preventionTips":["Pick one rule-selection mode per invocation: enable-only or disable-list.","Use -e/--enable with an explicit whitelist instead of mixing modes.","Sanitize shell aliases that implicitly add -eo."],"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"}