diff options
author | Soispha <soispha@vhack.eu> | 2023-06-18 16:43:49 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-06-18 16:43:49 +0200 |
commit | 6bc393444d415d50144b2c213812ce57eae1c01f (patch) | |
tree | 4f8785367b2396d07e878f3b0e80096accd015ae | |
parent | Fix(cli): Remove project option (diff) | |
download | lpm-6bc393444d415d50144b2c213812ce57eae1c01f.tar.gz lpm-6bc393444d415d50144b2c213812ce57eae1c01f.zip |
Style(treewide): Format
-rw-r--r-- | src/data.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | src/new/chapter.rs | 14 | ||||
-rw-r--r-- | src/new/mod.rs | 2 | ||||
-rw-r--r-- | src/new/project.rs | 15 |
5 files changed, 18 insertions, 18 deletions
diff --git a/src/data.rs b/src/data.rs index 4966e88..72609b8 100644 --- a/src/data.rs +++ b/src/data.rs @@ -11,7 +11,6 @@ pub struct LastChapter { pub number: u32, } - //fn main() { // let config: Config = toml::from_str(r#" // ip = '127.0.0.1' diff --git a/src/main.rs b/src/main.rs index b1d0563..b19e7bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,9 +4,7 @@ use command_line_interface::{ Command::New, SubCommand::{Chapter, Section}, }; -use new::{ - chapter::generate_new_chapter, section::generate_new_section, -}; +use new::{chapter::generate_new_chapter, section::generate_new_section}; pub mod command_line_interface; pub mod data; diff --git a/src/new/chapter.rs b/src/new/chapter.rs index 9cc12d0..88f2a85 100644 --- a/src/new/chapter.rs +++ b/src/new/chapter.rs @@ -9,7 +9,6 @@ use crate::data::Data; use super::{get_project_root, CHAPTER}; - pub fn generate_new_chapter(name: String) -> io::Result<()> { let project_root = get_project_root().unwrap(); @@ -22,10 +21,14 @@ pub fn generate_new_chapter(name: String) -> io::Result<()> { "content/{}/chapter_{:02}.tex", name.to_case(Case::Snake), data_file.last_chapter.number + 1 - ))).unwrap(); - new_chapter.write_all(CHAPTER.replace("REPLACEMENT_CHAPTER", &name).as_bytes()).unwrap(); + ))) + .unwrap(); + new_chapter + .write_all(CHAPTER.replace("REPLACEMENT_CHAPTER", &name).as_bytes()) + .unwrap(); - fs::create_dir(project_root.join(format!("content/{}/sections", name.to_case(Case::Snake),))).unwrap(); + fs::create_dir(project_root.join(format!("content/{}/sections", name.to_case(Case::Snake),))) + .unwrap(); main_file = main_file.replace( &format!( @@ -55,7 +58,8 @@ pub fn generate_new_chapter(name: String) -> io::Result<()> { fs::write( project_root.join("lpm.toml"), toml::to_string(&data_file).expect("We changed it ourselfes, the conversion should work"), - ).unwrap(); + ) + .unwrap(); fs::write(project_root.join("main.tex"), main_file).unwrap(); diff --git a/src/new/mod.rs b/src/new/mod.rs index efc55cd..33783c4 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -62,8 +62,6 @@ const MAIN_FILE: &'static str = r#"%\documentclass[a4paper, 12pt, nosolutions]{r \end{document} "#; - - pub fn get_project_root() -> io::Result<PathBuf> { let path = env::current_dir()?; let mut path_ancestors = path.as_path().ancestors(); diff --git a/src/new/project.rs b/src/new/project.rs index e04d138..56edead 100644 --- a/src/new/project.rs +++ b/src/new/project.rs @@ -6,17 +6,15 @@ use std::{ process::Command, }; - use convert_case::{Case, Casing}; use crate::data::Data; -use super::{TITLE_FILE, CHAPTER, MAIN_FILE}; +use super::{CHAPTER, MAIN_FILE, TITLE_FILE}; const NEEDED_DIRECTORYS: &'static [&'static str] = &["build", "content", "headers", "references", "resources"]; - pub fn generate_new_project( name: String, first_chapter: String, @@ -41,7 +39,12 @@ pub fn generate_new_project( let mut title_file = File::create("title.tex").unwrap(); title_file.write_all(TITLE_FILE.as_bytes()).unwrap(); - env::set_current_dir(project_root.join("content").join(&first_chapter.to_case(Case::Snake))).unwrap(); + env::set_current_dir( + project_root + .join("content") + .join(&first_chapter.to_case(Case::Snake)), + ) + .unwrap(); fs::create_dir("sections").unwrap(); let mut chapter_file = File::create("chapter_01.tex").unwrap(); chapter_file @@ -102,9 +105,7 @@ pub fn generate_new_project( .expect("failed to execute process"); let mut lpm_file = File::create(".gitignore").unwrap(); - lpm_file - .write_all(b"/build") - .unwrap(); + lpm_file.write_all(b"/build").unwrap(); Ok(()) } |