Skip to content

Commit

Permalink
Ran cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
404salad committed Sep 5, 2024
1 parent e3f901e commit 152cb2d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
29 changes: 16 additions & 13 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt;
use serde::Deserialize;
use std::io::{self,Write};
use std::env;
use std::fmt;
use std::fs::read_to_string;

use std::io::{self, Write};

#[derive(Deserialize)]
pub struct UserConfig {
Expand All @@ -11,9 +11,13 @@ pub struct UserConfig {
}

impl fmt::Display for UserConfig {
fn fmt(&self, f:&mut fmt::Formatter) -> fmt::Result {
write!(f, "author name > {} \nblog name > {}
", self.author_name, self.blog_name)
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"author name > {} \nblog name > {}
",
self.author_name, self.blog_name
)
}
}

Expand All @@ -40,15 +44,14 @@ pub fn initial_config () {
}
*/

pub fn read_config() -> Result<UserConfig, toml::de::Error>{
let config_file_data = match read_to_string("config.toml"){
Ok(d) => {d},
Err(_) => {String::new()}
pub fn read_config() -> Result<UserConfig, toml::de::Error> {
let config_file_data = match read_to_string("config.toml") {
Ok(d) => d,
Err(_) => String::new(),
};

let config: UserConfig = toml::from_str(&config_file_data)?;

Ok(config)

println!("fwe");
Ok(config)
}

39 changes: 18 additions & 21 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
pub mod parse_one_article;
pub mod consolidate_into_homepage;
pub mod config;
pub mod consolidate_into_homepage;
pub mod parse_one_article;
pub mod utils;

use std::thread;
use std::time::Duration;
use std::env;
use std::fs;
use std::thread;
use std::time::Duration;

use console::Term;

fn main() {


let term = Term::stdout();
term.clear_screen();
term.write_line("
term.write_line(
"
██████ ██████ ███ ██ ██████ ███████ ███████ ██████
██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ██ ██ ██ ███████ ███████ ██ ███
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██████ ██ ████ ██████ ███████ ███████ ██████
");
",
);
thread::sleep(Duration::from_millis(200));
term.write_line(" A simple cli tool to convert markdown to blog");

// TODO: only run this function if config toml doesnt exist
// TODO: only run this function if config toml doesnt exist
//config::initial_config();

let user_config = config::read_config().unwrap();
println!("{}",user_config);
println!("{}", user_config);

// Remove previous content (clean)
let article_dir = fs::read_dir("dist/articles");
utils::delete_dir_contents(article_dir);
Expand All @@ -39,7 +39,7 @@ fn main() {
println!("{:?}", article_names);
// rebuilding all the articles in content directory
for article_name in article_names {
match parse_one_article::markdown_to_styled_html(&article_name, &user_config){
match parse_one_article::markdown_to_styled_html(&article_name, &user_config) {
Ok(_) => {
println!("succesful parse")
}
Expand All @@ -49,14 +49,11 @@ fn main() {
};
}
match consolidate_into_homepage::create_homepage(&user_config) {
Ok(_) => {
println!("succesfully created homepage")
}
Err(e) => {
eprintln!("unsuccesful in creating homepage {}", e)
}
Ok(_) => {
println!("succesfully created homepage")
}
Err(e) => {
eprintln!("unsuccesful in creating homepage {}", e)
}
};


}

0 comments on commit 152cb2d

Please sign in to comment.