{"record":{"id":"2673cfe8c9f55391","repo":"Hmbown/CodeWhale","slug":"flag-must-be-placed-before-exec-use-codew","errorCode":null,"errorMessage":"{flag} must be placed before `exec`.\n\nUse:\n  codewhale {flag} exec \"<prompt>\"","messagePattern":"(.+?) must be placed before `exec`\\.\n\nUse:\n  codewhale (.+?) exec \"<prompt>\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":2183,"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\nfn run_login_command(store: &mut ConfigStore, args: LoginArgs) -> Result<()> {\n    run_login_command_with_secrets(store, args, &Secrets::auto_detect())\n}\n\nfn run_login_command_with_secrets(\n    store: &mut ConfigStore,\n    args: LoginArgs,\n    secrets: &Secrets,\n) -> Result<()> {\n    let provider: ProviderKind = args.provider.unwrap_or(ProviderArg::Deepseek).into();","sourceCodeStart":2165,"sourceCodeEnd":2201,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/cli/src/lib.rs#L2165-L2201","documentation":"`reject_exec_global_flags` scans the arguments before a `--` separator and rejects the global-only flags `--provider`, `--model`, `--api-key`, and `--base-url` when they appear after the `exec` subcommand. These flags configure the runtime globally and must precede `exec`; the message shows the corrected invocation with `{flag} <value>` moved in front.","triggerScenarios":"`codewhale exec --provider deepseek \"...\"`, `codewhale exec --model auto ...`, or any exec invocation carrying one of the four global flags (with or without `=`) before the `--` separator; also triggered by flags after `exec` but intended for the outer CLI.","commonSituations":"Muscle memory from CLIs where flags can go anywhere; scripts migrated from tools with per-subcommand provider flags; copy-pasting a provider flag into the prompt-adjacent position.","solutions":["Move the flag before the subcommand: `codewhale --provider <value> exec \"<prompt>\"`","For `=`-style flags, likewise hoist them: `codewhale --model=deepseek-v4-pro exec ...`","If you truly need to pass a literal `--provider` token to the prompt, place it after `--`"],"exampleFix":"# before\n$ codewhale exec --provider deepseek \"review this diff\"\n\n# after\n$ codewhale --provider deepseek exec \"review this diff\"","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# hoist global flags in front of exec before invoking\nprovider=\"deepseek\"; model=\"deepseek-v4-pro\"; prompt=\"review this diff\"\nexec codewhale --provider \"$provider\" --model \"$model\" exec -- \"$prompt\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt the habit: global flags (`--provider`, `--model`, `--api-key`, `--base-url`) always before the subcommand","Use `--` before the prompt so literal flag-looking words are not parsed as flags","Wrap codewhale in a small arg-ordering helper if team members keep tripping on this"],"tags":["cli","arguments","flag-placement","exec","usage-error"],"backgroundTag":"invalid-cli-arguments","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}