Direct debug messages to stderr instead of stdout

This commit is contained in:
Zykino 2019-09-15 12:47:36 +02:00
parent 38980f8d8a
commit d5ff39c401
2 changed files with 14 additions and 16 deletions

View File

@ -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");
//}

View File

@ -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);
}