Direct debug messages to stderr instead of stdout
This commit is contained in:
parent
38980f8d8a
commit
d5ff39c401
18
src/lib.rs
18
src/lib.rs
@ -30,10 +30,10 @@ pub struct Opt {
|
|||||||
// #[structopt(short, long)]
|
// #[structopt(short, long)]
|
||||||
// pub prefix: &str,
|
// pub prefix: &str,
|
||||||
|
|
||||||
// TODO: implement the recursivity
|
// // TODO: implement the recursivity
|
||||||
/// Recursively treat each child folder as a it's own comic to bind
|
// /// Recursively treat each child folder as a it's own comic to bind
|
||||||
#[structopt(short, long)]
|
// #[structopt(short, long)]
|
||||||
pub recursive: bool,
|
// pub recursive: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Opt {
|
impl Opt {
|
||||||
@ -55,7 +55,7 @@ struct Page {
|
|||||||
|
|
||||||
impl Page {
|
impl Page {
|
||||||
fn new(prefix: String, number: String, suffix: String) -> 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 {
|
Page {
|
||||||
prefix,
|
prefix,
|
||||||
number,
|
number,
|
||||||
@ -64,12 +64,12 @@ impl Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn original_filename(&self) -> String {
|
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)
|
format!("{}{}{}", self.prefix, self.number, self.suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_filename(&self, pad: usize) -> String {
|
fn new_filename(&self, pad: usize) -> String {
|
||||||
println!(
|
eprintln!(
|
||||||
"NF p: '{}' n: '{}' s: '{}'",
|
"NF p: '{}' n: '{}' s: '{}'",
|
||||||
self.prefix, self.number, self.suffix
|
self.prefix, self.number, self.suffix
|
||||||
);
|
);
|
||||||
@ -112,14 +112,14 @@ impl ComicBook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind(&mut self) {
|
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() {
|
for page in self.pages.iter() {
|
||||||
//if let Some(pos) = page.position {
|
//if let Some(pos) = page.position {
|
||||||
let original_file = page.original_filename();
|
let original_file = page.original_filename();
|
||||||
let new_file = page.new_filename(pad);
|
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");
|
// fs::rename(original_file, new_file).expect("RENAME FAILED");
|
||||||
//}
|
//}
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -9,16 +9,14 @@ fn main() {
|
|||||||
let opt = Opt::new(env::args());
|
let opt = Opt::new(env::args());
|
||||||
dbg!(&opt);
|
dbg!(&opt);
|
||||||
|
|
||||||
if opt.recursive
|
// if opt.recursive
|
||||||
/*|| opt.prefix*/
|
// /*|| opt.prefix*/
|
||||||
{
|
// {
|
||||||
unimplemented!();
|
// unimplemented!();
|
||||||
}
|
// }
|
||||||
|
|
||||||
env::set_current_dir(opt.comic_folder).unwrap();
|
env::set_current_dir(opt.comic_folder).unwrap();
|
||||||
let mut book = ComicBook::new(fs::read_dir(".").unwrap(), opt.pad);
|
let mut book = ComicBook::new(fs::read_dir(".").unwrap(), opt.pad);
|
||||||
|
|
||||||
book.bind();
|
book.bind();
|
||||||
|
|
||||||
// dbg!(book);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user