{"record":{"id":"3b843c3caf5e8a05","repo":"flxzt/rnote","slug":"output-file-and-output-format-are-mutually","errorCode":null,"errorMessage":"\"--output-file\" and \"--output-format\" are mutually exclusive.","messagePattern":"\"--output-file\" and \"--output-format\" are mutually exclusive\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rnote-cli/src/export.rs","lineNumber":301,"sourceCode":"    no_background: bool,\n    no_pattern: bool,\n    optimize_printing: bool,\n    page_order: SplitOrder,\n) -> anyhow::Result<DocExportPrefs> {\n    let format = match (output_file, output_format) {\n        (Some(file), None) => match file.as_ref().extension().and_then(|ext| ext.to_str()) {\n            Some(extension) => doc_export_format_from_ext_str(extension)?,\n            None => {\n                return Err(anyhow::anyhow!(\n                    \"The output file \\\"{}\\\" needs to have a supported extension to determine its file type.\",\n                    file.as_ref().display()\n                ));\n            }\n        },\n        (None, Some(out_format)) => out_format,\n        // should be unreachable because the arguments are exclusive (clap conflicts_with)\n        (Some(_), Some(_)) => {\n            return Err(anyhow::anyhow!(\n                \"\\\"--output-file\\\" and \\\"--output-format\\\" are mutually exclusive.\"\n            ));\n        }\n        // should be unreachable because either --output-file or --output-format is required\n        (None, None) => {\n            return Err(anyhow::anyhow!(\n                \"Either \\\"--output-file\\\" or \\\"--output-format\\\" is required.\"\n            ));\n        }\n    };\n\n    let prefs = DocExportPrefs {\n        export_format: format,\n        with_background: !no_background,\n        with_pattern: !no_pattern,\n        optimize_printing,\n        page_order,\n    };","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-cli/src/export.rs#L283-L319","documentation":"--output-file and --output-format both specify the export target format, so they cannot be combined. clap's conflicts_with normally prevents this at parse time; this arm is a defensive unreachable fallback in create_doc_export_prefs_from_args that still returns a clear error if both are somehow Some.","triggerScenarios":"Passing both --output-file and --output-format to a doc export. Normally blocked by clap conflict validation; reachable only if CLI constraints change or run_export internals are called directly with both set.","commonSituations":"Scripts that append both flags from separate config sources; manually constructed argument vectors bypassing clap conflicts.","solutions":["Keep only one of the two flags: use --output-file <path> (format inferred) or --output-format <fmt>.","If a script adds both, make it choose --output-format when no explicit output path is needed.","If you need both, derive the file path from the format instead (e.g. out.<format>)."],"exampleFix":"// before\nrnote export doc notes.rnote --output-file out.svg --output-format pdf\n// after\nrnote export doc notes.rnote --output-format pdf","handlingStrategy":"validation","validationCode":"set -- $(echo \"$ARGS\" | tr ' ' '\\n'); c=0; for a in \"$@\"; do case \"$a\" in --output-file|--output-format) c=$((c+1));; esac; done; [ \"$c\" -le 1 ] || { echo \"pick one: --output-file or --output-format\"; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine --output-file and --output-format in one invocation.","Centralize flag construction in one place so conflicts cannot creep in.","Prefer --output-format in scripts, --output-file interactively."],"tags":["cli","conflicting-options"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}