{"record":{"id":"deb57f124ba54232","repo":"Hmbown/CodeWhale","slug":"flag-must-be-placed-before-exec-use-codewhale-flag-value","errorCode":null,"errorMessage":"{flag} must be placed before `exec`.\n\nUse:\n  codewhale {flag} <value> exec \"<prompt>\"","messagePattern":"(.+?) must be placed before `exec`\\.\n\nUse:\n  codewhale (.+?) <value> exec \"<prompt>\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":2516,"sourceCode":"    forwarded.push(command.to_string());\n    forwarded.extend(args.args);\n    forwarded\n}\n\nfn setup_is_status_report(args: &TuiPassthroughArgs) -> bool {\n    args.args.iter().any(|arg| arg == \"--status\")\n}\n\nfn reject_exec_global_flags(args: &[String]) -> Result<()> {\n    const GLOBAL_ONLY_FLAGS: &[&str] = &[\"--provider\", \"--model\", \"--api-key\", \"--base-url\"];\n\n    for arg in args {\n        if arg == \"--\" {\n            break;\n        }\n        let flag = arg.split_once('=').map_or(arg.as_str(), |(flag, _)| flag);\n        if GLOBAL_ONLY_FLAGS.contains(&flag) {\n            bail!(\n                \"{flag} must be placed before `exec`.\\n\\nUse:\\n  codewhale {flag} <value> exec \\\"<prompt>\\\"\"\n            );\n        }\n    }\n\n    Ok(())\n}\n\n/// `codewhale login` used to configure provider API keys; that surface moved\n/// to `auth set --provider`. The hidden legacy flags stay parseable so the\n/// redirect below can name the replacement instead of an unknown-flag error.\nfn reject_legacy_login_provider_args(args: &LoginArgs) -> Result<()> {\n    if args.api_key.is_none() && args.provider.is_none() {\n        return Ok(());\n    }\n    bail!(\n        \"`codewhale login` now signs in to your Codewhale account via the browser device flow. \\\n         To configure a provider key, run `codewhale auth set --provider <provider>` (hidden prompt) \\","sourceCodeStart":2498,"sourceCodeEnd":2534,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/lib.rs#L2498-L2534","documentation":"Codewhale's exec subcommand validates that global-only flags (like --model, --provider) are not passed after the `exec` keyword. Args are scanned up to `--` and any recognized global flag placed in the exec position causes a bail with usage guidance. This keeps argument parsing unambiguous between the global CLI layer and the exec subcommand.","triggerScenarios":"Running `codewhale exec \"<prompt>\" --model <value>` (or any flag in GLOBAL_ONLY_FLAGS) after `exec`, before any `--` separator.","commonSituations":"Users copying global invocations from docs/examples and appending exec at the end; scripts built by reordering an existing working command; muscle memory from other CLIs that accept subcommand-level model overrides.","solutions":["Move the flag before `exec`: `codewhale --model <value> exec \"<prompt>\"`","If the value must stay inline, place `--` before it or remove the flag if a subcommand equivalent exists"],"exampleFix":"// before\ncodewhale exec \"refactor this\" --model gpt-5\n// after\ncodewhale --model gpt-5 exec \"refactor this\"","handlingStrategy":"validation","validationCode":"const GLOBAL_ONLY = ['--model', '--provider'];\nconst i = argv.indexOf('exec');\nif (i !== -1 && argv.slice(0, i).some(a => GLOBAL_ONLY.includes(a.split('=')[0]) === false)) throw new Error('move global flags before exec');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always order CLI args as `codewhale <global flags> exec \"<prompt>\"`","Wrap complex invocations in shell functions with flags fixed in the global position"],"tags":["cli","argument-order","flags"],"backgroundTag":"invalid-cli-argument","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}