generated from OBJNULL/Dockerized-Rust
Compare commits
3 commits
6173c83da5
...
d4313f421a
Author | SHA1 | Date | |
---|---|---|---|
d4313f421a | |||
6fb06f92be | |||
82edf42867 |
3 changed files with 18 additions and 7 deletions
|
@ -5,5 +5,6 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
pdf-extract = "0.9.0"
|
||||
colored = "3.0.0"
|
||||
clap = "4.5.36"
|
||||
csv = "1.3.1"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
mod action;
|
||||
mod args;
|
||||
mod parser;
|
||||
mod printer;
|
||||
mod reader;
|
||||
mod writer;
|
||||
|
||||
|
@ -18,31 +19,29 @@ fn main() -> Result<()> {
|
|||
let args = Arguments::new();
|
||||
|
||||
// Display Status
|
||||
println!("Reading PDF and extracting Text Content...");
|
||||
printer::print_generic("📃", "Extracting Text");
|
||||
|
||||
// Creating a File Reader & Reading
|
||||
let reader = Reader::new(&args.file_input.clone())?;
|
||||
let text = reader.extract();
|
||||
|
||||
// Display Status
|
||||
println!("Successfully extracted Text Content!");
|
||||
println!("Parsing the PDF...");
|
||||
printer::print_generic("📑", "Parsing Text");
|
||||
|
||||
// Creating a Parser to read the Text Content
|
||||
let mut parser = Parser::new(text);
|
||||
parser.start();
|
||||
|
||||
// Display Status
|
||||
println!("Successfully parsed the PDF!");
|
||||
println!("Saving to a CSV File...");
|
||||
printer::print_generic("📝", "Writing CSV");
|
||||
|
||||
// Creating a Writer and saving the file
|
||||
let writer = Writer::new(&parser.transactions, args.file_output.clone());
|
||||
writer.save()?;
|
||||
|
||||
// Display Status
|
||||
println!("Sucessfully Saved to {}", args.file_output);
|
||||
println!("Thank you for using Statement Converter!");
|
||||
printer::print_generic("🏁", "Successful Converting Job");
|
||||
printer::print_generic("😎", "Thank you for using Statement Converter!");
|
||||
|
||||
// It's ok!
|
||||
Ok(())
|
||||
|
|
11
project/src/printer.rs
Normal file
11
project/src/printer.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Libraries
|
||||
use colored::{self, Colorize, CustomColor};
|
||||
|
||||
// Functions
|
||||
pub fn print_generic(emoji: &str, message: &str) {
|
||||
println!(
|
||||
"[{:^3}] {}",
|
||||
emoji,
|
||||
message.custom_color(CustomColor::new(200, 200, 200))
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue