Merge pull request #433 from whoan/reduce-loc

Reduce lines of code
This commit is contained in:
Denis Isidoro 2020-10-30 09:57:35 -03:00 committed by GitHub
commit 0ddf77c1b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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))?;