{"record":{"id":"c1214af5394097d0","repo":"Morganamilo/paru","slug":"option-expects-a-value","errorCode":null,"errorMessage":"option {} expects a value","messagePattern":"option (.+?) expects a value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/command_line.rs","lineNumber":134,"sourceCode":"                }\n                self.handle_arg(arg, None, op_count, false)?;\n            }\n            Ok(false)\n        } else {\n            self.targets.push(arg.to_string());\n            Ok(false)\n        }\n    }\n\n    fn handle_arg(\n        &mut self,\n        arg: Arg,\n        mut value: Option<&str>,\n        op_count: &mut u8,\n        forced: bool,\n    ) -> Result<()> {\n        match takes_value(arg) {\n            TakesValue::Required if value.is_none() => bail!(tr!(\"option {} expects a value\", arg)),\n            _ => (),\n        }\n\n        if takes_value(arg) != TakesValue::Required && !forced {\n            value = None;\n        }\n\n        if arg.is_pacman_global() {\n            self.globals.args.push(crate::args::Arg {\n                key: arg.arg(),\n                value: value.map(|s| s.to_string()),\n            });\n            self.args.args.push(crate::args::Arg {\n                key: arg.arg(),\n                value: value.map(|s| s.to_string()),\n            });\n        }\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/Morganamilo/paru/blob/9ac3578807a87858651e81a02586ceb947686e7c/src/command_line.rs#L116-L152","documentation":"This is a command-line argument validation failure inside handle_arg (src/command_line.rs), the per-argument dispatcher invoked by parse_arg while building the Config from argv. It fires when the parser matched an option that is registered by takes_value() as TakesValue::Required (an option whose value is not optional) but no value could be attached to it: the option was the last token on the command line, or it appeared in a position where the parser explicitly passes value=None (such as the non-forced handle_arg call for bare arguments). Because there is no sane default for a mandatory option's payload, handle_arg bails out of the whole parse instead of continuing, aborting startup.","triggerScenarios":"Passing a value-requiring flag like `--sortby`, `--limit`, `--completioninterval`, or `--searchby` without an `=value` or a following argument, e.g. `--sortby` alone, or as the last token on the command line.","commonSituations":"Users typing a flag without its value or forgetting the `=`; shell scripts dropping an empty variable (`--limit \"$EMPTY\"`); truncated commands in CI pipelines.","solutions":["Supply the value: `--sortby name` or `--sortby=name`","Check scripts for empty variables used as option values","Consult `--help` to see which options require a value"],"exampleFix":"// before\nargs: [\"--sortby\"]\n// after\nargs: [\"--sortby\", \"name\"]  // or \"--sortby=name\"","handlingStrategy":"validation","validationCode":"const REQUIRES_VALUE: &[&str] = &[\"sortby\", \"searchby\", \"limit\", \"completioninterval\", \"sortby\"];\nfunction validate_args(args: string[]): string | null {\n  for (let i = 0; i < args.length; i++) {\n    const name = args[i].split('=')[0].replace(/^--?/, '');\n    if (REQUIRES_VALUE.includes(name) && !args[i].includes('=') && i + 1 >= args.length)\n      return `--${name} expects a value`;\n  }\n  return null;\n}","typeGuard":null,"tryCatchPattern":"match cli::parse(&args) {\n    Err(e) if e.to_string().contains(\"expects a value\") => {\n        eprintln!(\"{}; usage: --option value or --option=value\", e);\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n    Ok(cmd) => cmd.run(),\n}","preventionTips":["Always pass the value in the same token using `=` syntax: `--limit=5`","Validate CLI args in shell scripts before exec","Check `--help` for which options take values"],"tags":["cli","argument-parsing","missing-value"],"backgroundTag":"missing-required-argument","analyzedSha":"9ac3578807a87858651e81a02586ceb947686e7c","analyzedAt":"2026-09-12T04:57:59.861Z","contentChangedAt":"2026-09-12T04:57:59.861Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}