Reduce lines of code

This commit is contained in:
Juan Eugenio Abadie 2020-10-30 08:49:31 -03:00
parent 6dcbcfea54
commit 43d16025d2

View file

@ -149,9 +149,7 @@ pub fn read_lines(
} }
// tag // tag
else if line.starts_with('%') { else if line.starts_with('%') {
if write_cmd(&tags, &comment, &snippet, writer, stdin).is_err() { should_break = write_cmd(&tags, &comment, &snippet, writer, stdin).is_err();
should_break = true
}
snippet = String::from(""); snippet = String::from("");
tags = without_prefix(&line); tags = without_prefix(&line);
} }
@ -165,17 +163,13 @@ pub fn read_lines(
} }
// comment // comment
else if line.starts_with('#') { else if line.starts_with('#') {
if write_cmd(&tags, &comment, &snippet, writer, stdin).is_err() { should_break = write_cmd(&tags, &comment, &snippet, writer, stdin).is_err();
should_break = true
}
snippet = String::from(""); snippet = String::from("");
comment = without_prefix(&line); comment = without_prefix(&line);
} }
// variable // variable
else if line.starts_with('$') { else if line.starts_with('$') {
if write_cmd(&tags, &comment, &snippet, writer, stdin).is_err() { should_break = write_cmd(&tags, &comment, &snippet, writer, stdin).is_err();
should_break = true
}
snippet = String::from(""); snippet = String::from("");
let (variable, command, opts) = parse_variable_line(&line) let (variable, command, opts) = parse_variable_line(&line)
.with_context(|| format!("Failed to parse variable line. See line number {} in cheatsheet `{}`", line_nr + 1, id))?; .with_context(|| format!("Failed to parse variable line. See line number {} in cheatsheet `{}`", line_nr + 1, id))?;