Fix missing

This commit is contained in:
Thomas Forgione 2019-02-12 10:47:14 +01:00
parent c44c9fe789
commit 7eb4ae7848
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 8 additions and 6 deletions

View File

@ -4,13 +4,13 @@ use std::process::exit;
use std::io::{stdout, stdin, Write}; use std::io::{stdout, stdin, Write};
use std::num::Wrapping; use std::num::Wrapping;
use colored::*; use colored::*;
use gclone::Cache; use gclone::{Result, Cache};
fn flush_stdout() { fn flush_stdout() {
stdout().flush().ok(); stdout().flush().ok();
} }
fn main() { fn main() -> Result<()> {
let request = match env::args().nth(1) { let request = match env::args().nth(1) {
Some(arg) => arg, Some(arg) => arg,
None => { None => {
@ -22,12 +22,12 @@ fn main() {
}, },
}; };
main_with_cache(&request, true); main_with_cache(&request, true)
} }
fn main_with_cache(request: &str, regen: bool) { fn main_with_cache(request: &str, regen: bool) -> Result<()> {
let cache = Cache::read(); let cache = Cache::read()?;
let matches = cache.find(&request); let matches = cache.find(&request);
@ -39,7 +39,7 @@ fn main_with_cache(request: &str, regen: bool) {
"warning:".bold().yellow(), "warning:".bold().yellow(),
"directory not found, regenerating cache...".bold()); "directory not found, regenerating cache...".bold());
let cache = Cache::new(); let cache = Cache::new()?;
match cache.write() { match cache.write() {
Ok(_) => (), Ok(_) => (),
@ -120,6 +120,8 @@ fn main_with_cache(request: &str, regen: bool) {
}, },
} }
Ok(())
} }