{"record":{"id":"3900f4ccb7e75e48","repo":"rust-lang/cargo","slug":"argument-for-color-must-be-auto-always-or-neve-3900f4","errorCode":null,"errorMessage":"argument for --color must be auto, always, or never, but found `{}`","messagePattern":"argument for --color must be auto, always, or never, but found `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/xtask-spellcheck/src/main.rs","lineNumber":69,"sourceCode":"            Arg::new(\"write-changes\")\n                .long(\"write-changes\")\n                .short('w')\n                .help(\"Write fixes out\")\n                .action(ArgAction::SetTrue)\n                .global(true),\n        )\n}\n\npub fn exec(matches: &clap::ArgMatches) -> Result<()> {\n    let mut args = vec![];\n\n    match matches.get_one::<String>(\"color\") {\n        Some(c) if matches!(c.as_str(), \"auto\" | \"always\" | \"never\") => {\n            args.push(\"--color\");\n            args.push(c);\n        }\n        Some(c) => {\n            anyhow::bail!(\n                \"argument for --color must be auto, always, or \\\n                 never, but found `{}`\",\n                c\n            );\n        }\n        _ => {}\n    }\n\n    if matches.get_flag(\"quiet\") {\n        args.push(\"--quiet\");\n    }\n\n    let verbose_count = matches.get_count(\"verbose\");\n\n    for _ in 0..verbose_count {\n        args.push(\"--verbose\");\n    }\n    if matches.get_flag(\"write-changes\") {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/crates/xtask-spellcheck/src/main.rs#L51-L87","documentation":"xtask-spellcheck wraps the `typos` CLI and forwards a --color argument. It validates that the value is exactly 'auto', 'always', or 'never'; any other value bails with the standard Cargo color-argument message. This duplicates ColorChoice::from_str's contract at the spellcheck entrypoint.","triggerScenarios":"Running `cargo spellcheck --color yes` (or 'on'/'force'/'true') — the value fails the match against the three accepted strings.","commonSituations":"Aliases or wrapper scripts passing boolean-style color values; copy-pasted flags from other tools that accept 'yes'/'on'.","solutions":["Use one of: auto, always, never.","Normalize user input in your wrapper to these exact strings.","Drop the flag entirely to rely on auto-detection."],"exampleFix":"// before\ncargo spellcheck --color yes\n// after\ncargo spellcheck --color always","handlingStrategy":"validation","validationCode":"fn valid_color(s: &str) -> bool {\n    matches!(s, \"auto\" | \"always\" | \"never\")\n}\nif let Some(c) = color_arg {\n    if !valid_color(c) { eprintln!(\"--color must be auto|always|never\"); }\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use clap value_parser to constrain the color argument.","Avoid boolean-style aliases in scripts."],"tags":["cargo","xtask","spellcheck","cli","color"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}