diff --git a/src/main.rs b/src/main.rs index 095e7c2..6dc04f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ const CONTEXT_KEY_LINENUM_SHORT: &str = "LN"; fn main() { let mut exit_code = 0; - let options = Options::from_args(); + let options = Options::from_args().with_defaults(); let rargs = Arc::new(Rargs::new(&options)); let stdin = io::stdin(); @@ -157,6 +157,15 @@ struct Options { cmd_and_args: Vec, } +impl Options { + pub fn with_defaults(mut self) -> Options { + if self.cmd_and_args.len() == 1 { + self.cmd_and_args.push("{}".to_string()); + } + self + } +} + #[derive(Debug)] struct Rargs { pattern: Regex,