expression
Clap end-of-options marker --
The conventional -- marker ends option parsing so a following positional value can begin with a hyphen. This is especially helpful with unusual filenames; the program does not access the file. Uses a fixed synthetic argument list or local data. Expected stdout (not executed): positional path accepted Common mistake: Interpreting every hyphen-prefixed filename as an option.
Formal Syntax & Structure
rust syntaxrust
Cli::try_parse_from(["search", "--", "-draft.txt"])Working Example
Example Snippetrust
fn main() { use clap::Parser; use std::path::PathBuf; #[derive(Parser)] struct Cli { path: PathBuf } let cli = Cli::try_parse_from(["search", "--", "-draft.txt"]).unwrap(); assert_eq!(cli.path, PathBuf::from("-draft.txt")); println!("positional path accepted");}