{"record":{"id":"4085de842280b9ad","repo":"sinelaw/fresh","slug":"too-many-line-arguments-at-most-one-is-allowed","errorCode":null,"errorMessage":"Too many '+<line>' arguments (at most one is allowed)","messagePattern":"Too many '\\+<line>' arguments \\(at most one is allowed\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/main.rs","lineNumber":1093,"sourceCode":"/// uses).\nfn apply_plus_line_args(files: Vec<String>) -> AnyhowResult<Vec<String>> {\n    let mut line: Option<usize> = None;\n    let mut plus_count = 0usize;\n    let mut rest: Vec<String> = Vec::with_capacity(files.len());\n    for f in files {\n        match parse_plus_line_arg(&f) {\n            Some(n) => {\n                plus_count += 1;\n                line = Some(n);\n            }\n            None => rest.push(f),\n        }\n    }\n    let Some(line) = line else {\n        return Ok(rest);\n    };\n    if plus_count > 1 {\n        anyhow::bail!(\"Too many '+<line>' arguments (at most one is allowed)\");\n    }\n    match rest.iter_mut().find(|f| f.as_str() != \"-\") {\n        Some(target) => {\n            // Only annotate a file that carries no explicit location\n            // yet — `fresh +50 file.txt:10` keeps the explicit 10.\n            // Remote specs (`user@host:path`, `ssh://…`) take the\n            // same `:line` suffix, so they work too.  A malformed\n            // `ssh://` target is left alone; it errors downstream.\n            let has_line = match parse_location(target) {\n                Ok(ParsedLocation::Local(fl)) => fl.line.is_some(),\n                Ok(ParsedLocation::Remote(rl)) => rl.line.is_some(),\n                Err(_) => true,\n            };\n            if !has_line {\n                target.push_str(&format!(\":{}\", line));\n            }\n            Ok(rest)\n        }","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/main.rs#L1075-L1111","documentation":"Validation guard in apply_plus_line_args that rejects command lines supplying more than one '+<line>' argument (e.g. `editor +5 +10 file.rs`). The editor accepts at most one start-line position; multiple ones are ambiguous, so the whole argument list is rejected before any file is opened rather than silently using the last or first value.","triggerScenarios":"Invoking the editor like `fresh +10 +20 file.txt` — more than one argument beginning with '+' is counted and rejected.","commonSituations":"Script aliases that already add a '+line' argument while the user adds another; copy-pasting multiple jump targets; misunderstanding the shorthand as repeatable per-file.","solutions":["Pass only one '+<line>' argument for the whole invocation","Use explicit file:line syntax for each file instead, e.g. `fresh file1.txt:10 file2.txt:20`","Fix wrapper scripts/aliases that inject a '+<line>' argument automatically","Keep the jump target in the file argument: `fresh +50 file.txt` == `fresh file.txt:50`"],"exampleFix":"// before\nfresh +10 +20 notes.txt\n// after\nfresh notes.txt:10\n# or per-file explicit locations:\nfresh a.txt:10 b.txt:20","handlingStrategy":"validation","validationCode":"let plus_args: Vec<_> = std::env::args().skip(1).filter(|a| a.starts_with('+') && a[1..].chars().all(|c| c.is_ascii_digit())).collect();\nif plus_args.len() > 1 { eprintln!(\"pass at most one +<line>\"); }","typeGuard":"fn is_plus_line_arg(a: &str) -> bool {\n    a.len() > 1 && a.starts_with('+') && a[1..].chars().all(|c| c.is_ascii_digit())\n}","tryCatchPattern":"match editor::launch(args) {\n    Err(e) => eprintln!(\"usage error: {e}\"),\n    Ok(()) => {},\n}","preventionTips":["Use file:line syntax for multiple per-file locations","Audit shell aliases/wrappers for auto-injected +line arguments","Remember +<line> is a single, whole-invocation jump target"],"tags":["cli","arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}