nikivdev/code · error
unknown `f pr preview` option: {token}
Error message
unknown `f pr preview` option: {token} What it means
The `f pr preview` argument parser only accepts --json, --mode, --base, and --path. Any other token reaches the catch-all arm of the match and produces this error naming the unrecognized token.
Source
Thrown at src/pr_preview.rs:304
};
mode = parse_mode_arg(value)?;
index += 2;
}
"--base" => {
let Some(value) = args.get(index + 1) else {
bail!("`f pr preview --base` requires a value");
};
requested_base = value.clone();
index += 2;
}
"--path" => {
let Some(value) = args.get(index + 1) else {
bail!("`f pr preview --path` requires a value");
};
repo_path = Some(PathBuf::from(value));
index += 2;
}
token => bail!("unknown `f pr preview` option: {token}"),
}
}
Ok(Some(PrPreviewCommand {
repo_path,
requested_base,
mode,
json,
}))
}
fn parse_mode_arg(value: &str) -> Result<PrPreviewModeArg> {
match value.trim().to_ascii_lowercase().as_str() {
"draft" => Ok(PrPreviewModeArg::Draft),
"feedback" => Ok(PrPreviewModeArg::Feedback),
other => bail!("unsupported `f pr preview --mode` value: {other}"),
}
}View on GitHub (pinned to a747e741ae)
Solutions
- Use only supported flags: --json, --mode, --base, --path
- Check spelling of the flag (the offending token is named in the message)
- Run the command without extra positional arguments
Example fix
// before f pr preview --mde draft // after f pr preview --mode draft
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED: [&str; 4] = ["--json", "--mode", "--base", "--path"];
for a in &args {
if a.starts_with("--") && !ALLOWED.contains(&a.as_str()) {
anyhow::bail!("unsupported flag: {a}");
}
} Try / catch
if let Err(e) = run_pr_preview(cmd) {
if e.to_string().starts_with("unknown `f pr preview` option") {
eprintln!("Supported flags: --json --mode --base --path");
}
} Prevention
- Only use --json, --mode, --base, --path with this subcommand
- Don't copy flags from other `f` subcommands
- Check flag spelling before running
When it happens
Trigger: Passing an unsupported flag such as `f pr preview --help-me`, a misspelled flag like `--mod`, or a stray positional argument.
Common situations: Typo'd flags; options valid for other `f` subcommands but not preview; leftover positional args from a different command's syntax.
Related errors
- `f pr preview --path` accepts at most one repo path override
- `f pr preview --mode` requires a value
- `f pr preview --base` requires a value
- `f pr preview --path` requires a value
- unsupported `f pr preview --mode` value: {other}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/a84c2d50f3f50cea.
Report an issue: GitHub.