{"record":{"id":"bdca004cfd2502bf","repo":"cross-rs/cross","slug":"argument-should-contain","errorCode":null,"errorMessage":"argument should contain `=`","messagePattern":"argument should contain `=`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.rs","lineNumber":128,"sourceCode":") -> Result<Option<T>> {\n    out.push(arg);\n    match iter.next() {\n        Some(next) => {\n            let result = parse(&next)?;\n            out.push(store_cb(next)?);\n            Ok(Some(result))\n        }\n        None => Ok(None),\n    }\n}\n\nfn parse_equal_arg<T>(\n    arg: String,\n    out: &mut Vec<String>,\n    parse: impl Fn(&str) -> Result<T>,\n    store_cb: impl Fn(String) -> Result<String>,\n) -> Result<T> {\n    let (first, second) = arg.split_once('=').expect(\"argument should contain `=`\");\n    let result = parse(second)?;\n    out.push(format!(\"{first}={}\", store_cb(second.to_owned())?));\n\n    Ok(result)\n}\n\nfn parse_manifest_path(path: &str) -> Result<Option<PathBuf>> {\n    let p = PathBuf::from(path);\n    Ok(absolute_path(p).ok())\n}\n\nfn parse_target_dir(path: &str) -> Result<PathBuf> {\n    absolute_path(PathBuf::from(path))\n}\n\nfn identity(arg: String) -> Result<String> {\n    Ok(arg)\n}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/cli.rs#L110-L146","documentation":"parse_equal_arg parses CLI arguments of the form `name=value`. It uses split_once('=') and unwraps the result with .expect(\"argument should contain `=`\"), so the message is raised as a panic (not an eyre error) whenever the argument lacks an '=' separator. The function contract is that callers only invoke it with arguments already known to be `key=value` shaped.","triggerScenarios":"Calling the xtask CLI with a flag that is routed through parse_equal_arg but supplied without '=', e.g. `--platform linux` instead of `--platform=linux`, or a bare flag with no value (`--platform`) reaching the parser.","commonSituations":"Users type a space-separated flag value out of habit (`--target x86_64-unknown-linux-gnu`) while the parser only accepts `--target=x86_64-unknown-linux-gnu`; scripts concatenate flags incorrectly, dropping the '='; an empty value still works but a completely malformed token (typo, stray space from shell quoting) panics.","solutions":["Use the `=` form for these flags: `--flag=value` with no space between the flag name and the value.","Check shell quoting/variable expansion so the argument reaches the parser as a single `name=value` token (e.g. quote \"--target=$TARGET\").","As a library fix, replace the expect with proper error handling returning a Result (map_err to a descriptive invalid-CLI-argument error) instead of panicking."],"exampleFix":"// before\n$ xtask run --target x86_64-unknown-linux-gnu\nthread 'main' panicked: argument should contain `=`\n\n// after\n$ xtask run --target=x86_64-unknown-linux-gnu","handlingStrategy":"validation","validationCode":"fn validate_equal_arg(arg: &str) -> Result<(), String> {\n    if arg.split_once('=').is_none() {\n        return Err(format!(\"argument `{arg}` must be in name=value form\"));\n    }\n    Ok(())\n}","typeGuard":"fn is_key_value(arg: &str) -> Option<(&str, &str)> { arg.split_once('=') }","tryCatchPattern":"catch_unwind(|| cli::parse(args)).unwrap_or_else(|_| {\n    eprintln!(\"invalid argument: expected --flag=value form (with '=')\");\n    std::process::exit(2);\n})","preventionTips":["Always use --flag=value syntax for xtask CLI options; no spaces around '='.","Quote interpolated values in shell scripts: \"--target=$TARGET\".","In library code, replace .expect with a Result-returning error for graceful CLI usage messages."],"tags":["cli","panic","argument-parsing","invalid-cli-argument"],"backgroundTag":"invalid-cli-argument","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}