diff --git a/src/error.rs b/src/error.rs index 4996c44..753c596 100644 --- a/src/error.rs +++ b/src/error.rs @@ -4,6 +4,7 @@ pub enum Error { InvalidStory(), SourceError(&'static str), + UserError(&'static str), } pub type Result = std::result::Result; diff --git a/src/main.rs b/src/main.rs index 43f06fd..0c8fedf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,30 @@ pub mod fetcher; pub mod parser; pub mod story; -fn main() { +use std::env::args; +use std::time::Instant; + +use crate::error::{Error, Result}; +use crate::fetcher::Fetcher; + +fn main() -> Result<()> { + use Error::*; + + let argv = args().collect::>(); + + let path = match argv.len() { + 2 => Ok(argv.get(1).unwrap()), + _ => Err(UserError("Usage: fimfareader ")), + }?; + println!("Hellopaca, World!"); + + let start = Instant::now(); + let fetcher = Fetcher::from(path)?; + let finish = Instant::now() - start; + + println!("Finished loading in {} milliseconds.", finish.as_millis()); + println!("The archive contains {} stories.", fetcher.iter().count()); + + Ok(()) }