DioxusLabs/dioxus · error · anyhow::Error
Only one of --file or --raw should be specified.
Error message
Only one of --file or --raw should be specified.
What it means
Argument guard in determine_input (called from translate): both the `--file` and `--raw` CLI options were supplied, but the translator accepts exactly one input source. The inputs at fault are the mutually exclusive file/raw arguments, and the guard fires before any input is read.
Source
Thrown at packages/cli/src/cli/translate.rs:112
out.push_str("\n}");
}
fn indent_and_write(raw: &str, idx: usize, out: &mut String) {
for line in raw.lines() {
for _ in 0..idx {
out.push_str(" ");
}
out.push_str(line);
out.push('\n');
}
}
fn determine_input(file: Option<String>, raw: Option<String>) -> Result<String> {
use std::io::IsTerminal as _;
// Make sure not both are specified
if file.is_some() && raw.is_some() {
bail!("Only one of --file or --raw should be specified.");
}
if let Some(raw) = raw {
return Ok(raw);
}
if let Some(file) = file {
return Ok(std::fs::read_to_string(file)?);
}
// If neither exist, we try to read from stdin
if std::io::stdin().is_terminal() {
bail!("No input file, source, or stdin to translate from.");
}
let mut buffer = String::new();
std::io::stdin().read_to_string(&mut buffer).unwrap();
View on GitHub (pinned to 24f6a829df)
Solutions
- Pass only one of --file or --raw to dx translate.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/cli/src/cli/translate.rs:112 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/5139437d14e41877.
Report an issue: GitHub.