From d5ff39c4011dc2085b3106f046ace7ca9a3e1c6e Mon Sep 17 00:00:00 2001 From: Zykino Date: Sun, 15 Sep 2019 12:47:36 +0200 Subject: [PATCH] Direct debug messages to stderr instead of stdout --- src/lib.rs | 18 +++++++++--------- src/main.rs | 12 +++++------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9957c77..8541d35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,10 +30,10 @@ pub struct Opt { // #[structopt(short, long)] // pub prefix: &str, - // TODO: implement the recursivity - /// Recursively treat each child folder as a it's own comic to bind - #[structopt(short, long)] - pub recursive: bool, + // // TODO: implement the recursivity + // /// Recursively treat each child folder as a it's own comic to bind + // #[structopt(short, long)] + // pub recursive: bool, } impl Opt { @@ -55,7 +55,7 @@ struct Page { impl Page { fn new(prefix: String, number: String, suffix: String) -> Page { - println!("N p:{} n: {} s: {}", prefix, number, suffix); + eprintln!("N p:{} n: {} s: {}", prefix, number, suffix); Page { prefix, number, @@ -64,12 +64,12 @@ impl Page { } fn original_filename(&self) -> String { - println!("OF p:{} n: {} s: {}", self.prefix, self.number, self.suffix); + eprintln!("OF p:{} n: {} s: {}", self.prefix, self.number, self.suffix); format!("{}{}{}", self.prefix, self.number, self.suffix) } fn new_filename(&self, pad: usize) -> String { - println!( + eprintln!( "NF p: '{}' n: '{}' s: '{}'", self.prefix, self.number, self.suffix ); @@ -112,14 +112,14 @@ impl ComicBook { } pub fn bind(&mut self) { - let pad = self.get_pad_size().unwrap(); + let pad = self.get_pad_size().expect("get_pad_size"); // TODO have a nice error message (the user may habe specifyed a folder that does not contains cb pages) for page in self.pages.iter() { //if let Some(pos) = page.position { let original_file = page.original_filename(); let new_file = page.new_filename(pad); - println!("{} -> {}", original_file, dbg!(new_file)); + eprintln!("{} -> {}", original_file, new_file); // fs::rename(original_file, new_file).expect("RENAME FAILED"); //} diff --git a/src/main.rs b/src/main.rs index e9df017..3e81d2b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,16 +9,14 @@ fn main() { let opt = Opt::new(env::args()); dbg!(&opt); - if opt.recursive - /*|| opt.prefix*/ - { - unimplemented!(); - } + // if opt.recursive + // /*|| opt.prefix*/ + // { + // unimplemented!(); + // } env::set_current_dir(opt.comic_folder).unwrap(); let mut book = ComicBook::new(fs::read_dir(".").unwrap(), opt.pad); book.bind(); - - // dbg!(book); }