summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorliv <liv@fastmail.com>2019-01-09 20:33:58 +0100
committerliv <liv@fastmail.com>2019-01-09 20:33:58 +0100
commite03a98cbf6491dcf36e8a96fda20764bc1e1748e (patch)
tree766db1a93071dd510219dc63872909481066c997 /src/main.rs
parenta388bb3798e2595c47924c6e4128f10e00cfc705 (diff)
rustfmt
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/main.rs b/src/main.rs
index 0fc0692..c229e0b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,19 +1,19 @@
-use clap::{App, Arg, SubCommand, crate_version};
-use syntect::easy::HighlightFile;
-use syntect::parsing::SyntaxSet;
-use syntect::highlighting::{ThemeSet, Style};
-use syntect::util::{as_24_bit_terminal_escaped};
+use crate::run::run;
+use crate::verify::verify;
+use clap::{crate_version, App, Arg, SubCommand};
+use notify::DebouncedEvent;
+use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use std::io::BufRead;
use std::sync::mpsc::channel;
use std::time::Duration;
-use notify::DebouncedEvent;
-use notify::{RecommendedWatcher, Watcher, RecursiveMode};
-use crate::verify::verify;
-use crate::run::run;
+use syntect::easy::HighlightFile;
+use syntect::highlighting::{Style, ThemeSet};
+use syntect::parsing::SyntaxSet;
+use syntect::util::as_24_bit_terminal_escaped;
mod run;
-mod verify;
mod util;
+mod verify;
fn main() {
let matches = App::new("rustlings")
@@ -26,11 +26,12 @@ fn main() {
SubCommand::with_name("run")
.alias("r")
.arg(Arg::with_name("file").required(true).index(1)),
- ).get_matches();
+ )
+ .get_matches();
let ss = SyntaxSet::load_defaults_newlines();
let ts = ThemeSet::load_defaults();
-
+
println!(r#" _ _ _ "#);
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#);
@@ -55,7 +56,8 @@ fn main() {
}
if let None = matches.subcommand_name() {
- let mut highlighter = HighlightFile::new("default_out.md", &ss, &ts.themes["base16-eighties.dark"]).unwrap();
+ let mut highlighter =
+ HighlightFile::new("default_out.md", &ss, &ts.themes["base16-eighties.dark"]).unwrap();
for maybe_line in highlighter.reader.lines() {
let line = maybe_line.unwrap();
let regions: Vec<(Style, &str)> = highlighter.highlight_lines.highlight(&line, &ss);
@@ -76,14 +78,11 @@ fn watch() -> notify::Result<()> {
loop {
match rx.recv() {
- Ok(event) => {
- match event {
- DebouncedEvent::Chmod(_)
- | DebouncedEvent::Write(_) => {
- let _ignored = verify();
- }
- _ => {}
+ Ok(event) => match event {
+ DebouncedEvent::Chmod(_) | DebouncedEvent::Write(_) => {
+ let _ignored = verify();
}
+ _ => {}
},
Err(e) => println!("watch error: {:?}", e),
}