Compare commits

...

3 commits

Author SHA1 Message Date
d4313f421a Created printer for better formatting 2025-04-18 16:25:36 -04:00
6fb06f92be Added Printer to Main Script 2025-04-18 16:25:30 -04:00
82edf42867 Added Colored Library 2025-04-18 16:25:21 -04:00
3 changed files with 18 additions and 7 deletions

View file

@ -5,5 +5,6 @@ edition = "2021"
[dependencies] [dependencies]
pdf-extract = "0.9.0" pdf-extract = "0.9.0"
colored = "3.0.0"
clap = "4.5.36" clap = "4.5.36"
csv = "1.3.1" csv = "1.3.1"

View file

@ -2,6 +2,7 @@
mod action; mod action;
mod args; mod args;
mod parser; mod parser;
mod printer;
mod reader; mod reader;
mod writer; mod writer;
@ -18,31 +19,29 @@ fn main() -> Result<()> {
let args = Arguments::new(); let args = Arguments::new();
// Display Status // Display Status
println!("Reading PDF and extracting Text Content..."); printer::print_generic("📃", "Extracting Text");
// Creating a File Reader & Reading // Creating a File Reader & Reading
let reader = Reader::new(&args.file_input.clone())?; let reader = Reader::new(&args.file_input.clone())?;
let text = reader.extract(); let text = reader.extract();
// Display Status // Display Status
println!("Successfully extracted Text Content!"); printer::print_generic("📑", "Parsing Text");
println!("Parsing the PDF...");
// Creating a Parser to read the Text Content // Creating a Parser to read the Text Content
let mut parser = Parser::new(text); let mut parser = Parser::new(text);
parser.start(); parser.start();
// Display Status // Display Status
println!("Successfully parsed the PDF!"); printer::print_generic("📝", "Writing CSV");
println!("Saving to a CSV File...");
// Creating a Writer and saving the file // Creating a Writer and saving the file
let writer = Writer::new(&parser.transactions, args.file_output.clone()); let writer = Writer::new(&parser.transactions, args.file_output.clone());
writer.save()?; writer.save()?;
// Display Status // Display Status
println!("Sucessfully Saved to {}", args.file_output); printer::print_generic("🏁", "Successful Converting Job");
println!("Thank you for using Statement Converter!"); printer::print_generic("😎", "Thank you for using Statement Converter!");
// It's ok! // It's ok!
Ok(()) Ok(())

11
project/src/printer.rs Normal file
View 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))
);
}