Skip to content

Commit

Permalink
Fix lotabout#14: argument without {}
Browse files Browse the repository at this point in the history
  • Loading branch information
meluskyc committed Oct 6, 2020
1 parent cdeedcc commit 6ecbaca
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -157,6 +157,15 @@ struct Options {
cmd_and_args: Vec<String>,
}

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,
Expand Down

0 comments on commit 6ecbaca

Please sign in to comment.