mirror of
https://github.com/JockeTF/fimfareader.git
synced 2024-11-23 13:58:00 +01:00
Add slightly interactive main function
This commit is contained in:
parent
f50f5bd65c
commit
d1f9f588d5
2 changed files with 26 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
pub enum Error {
|
||||
InvalidStory(),
|
||||
SourceError(&'static str),
|
||||
UserError(&'static str),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
|
26
src/main.rs
26
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::<Vec<String>>();
|
||||
|
||||
let path = match argv.len() {
|
||||
2 => Ok(argv.get(1).unwrap()),
|
||||
_ => Err(UserError("Usage: fimfareader <ARCHIVE>")),
|
||||
}?;
|
||||
|
||||
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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue