{"record":{"id":"f316b510b357e3fc","repo":"can1357/oh-my-pi","slug":"format-string-may-not-be-specified-when-printing-e","errorCode":null,"errorMessage":"format string may not be specified when printing equal width strings","messagePattern":"format string may not be specified when printing equal width strings","errorType":"error_code","errorClass":"SeqError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/seq.rs","lineNumber":448,"sourceCode":"\t///\n\t/// The parameters are the [`String`] argument as read from the\n\t/// command line and the underlying parsing error itself.\n\t#[error(\"invalid {} argument: {}\", parse_error_type(.1), .0.quote())]\n\tParseError(String, ParseNumberError),\n\n\t/// The increment argument was zero, which is not allowed.\n\t///\n\t/// The parameter is the increment argument as a [`String`] as read\n\t/// from the command line.\n\t#[error(\"invalid Zero increment value: {}\", .0.quote())]\n\tZeroIncrement(String),\n\n\t/// No arguments were passed to this function, 1 or more is required\n\t#[error(\"missing operand\")]\n\tNoArguments,\n\n\t/// Both a format and equal width where passed to seq\n\t#[error(\"format string may not be specified when printing equal width strings\")]\n\tFormatAndEqualWidth,\n}\n\nfn parse_error_type(e: &ParseNumberError) -> &'static str {\n\tmatch e {\n\t\tParseNumberError::Float => \"floating point\",\n\t\tParseNumberError::Nan => \"'not-a-number'\",\n\t}\n}\n\n}\n\nuse self::{error::SeqError, number::PreciseNumber};\n\nconst OPT_SEPARATOR: &str = \"separator\";\nconst OPT_TERMINATOR: &str = \"terminator\";\nconst OPT_EQUAL_WIDTH: &str = \"equal-width\";\nconst OPT_FORMAT: &str = \"format\";","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/seq.rs#L430-L466","documentation":"This is the `FormatAndEqualWidth` variant of the seq error enum. GNU seq's `--equal-width` (`-w`) pads all numbers to equal width, which is incompatible with a user-supplied `--format` (`-f`) string, since the format already dictates output width. The library rejects the mutually exclusive combination up front.","triggerScenarios":"Invoking the seq builtin with both a format string argument and the equal-width flag, e.g. `seq -f '%3.0f' -w 1 5`.","commonSituations":"Copy-pasted command lines where `-f` and `-w` accumulate from different option sources, or a user misunderstanding that `-w` and `-f` overlap in controlling output formatting.","solutions":["Remove the `--equal-width`/`-w` flag if you need a custom format.","Remove the `--format`/`-f` string if you need equal-width padding; `-w` alone pads with the default format.","Achieve custom formatting plus padding entirely in the format string, e.g. `-f '%3.0f'`.","If options come from config/variables, make them mutually exclusive in your argument assembly logic."],"exampleFix":"// before\nseq -f '%3.0f' -w 1 5\n\n// after\nseq -f '%3.0f' 1 5","handlingStrategy":"validation","validationCode":"let uses_format = args.iter().any(|a| a == \"-f\" || a == \"--format\");\nlet uses_equal_width = args.iter().any(|a| a == \"-w\" || a == \"--equal-width\");\nif uses_format && uses_equal_width {\n    eprintln!(\"seq: -f and -w are mutually exclusive\");\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"match seq_result {\n    Err(SeqError::FormatAndEqualWidth) => eprintln!(\"drop either -f or -w; they cannot be combined\"),\n    Err(e) => eprintln!(\"seq: {e}\"),\n    Ok(out) => print!(\"{out}\"),\n}","preventionTips":["Treat -f/--format and -w/--equal-width as mutually exclusive options.","Encode width/padding requirements fully in the -f format string when custom formatting is needed.","Add an arg-parsing unit test for the conflicting combination in wrapper scripts."],"tags":["cli","builtin","seq","conflicting-options"],"backgroundTag":"conflicting-cli-options","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}