diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 8d1c977..5ea9a74 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,18 +2,19 @@ use std::{env, ffi::OsString, fs, path::PathBuf}; use anyhow::{bail, Context}; use clap::Parser; +use cli::Command; use log::debug; use crate::{ cli::{ Args, - Command::New, What::{Chapter, Section}, }, config_file::Config, new::{chapter::generate_new_chapter, section::generate_new_section}, }; +pub mod bundle; pub mod cli; pub mod config_file; pub mod new; @@ -38,8 +39,14 @@ fn main() -> anyhow::Result<()> { let config_file = fs::read_to_string(project_root.join("lpm.toml"))?; let config: Config = toml::from_str(&config_file).context("Reading toml from string")?; - let file_tree = match args.cli { - New(new_command) => match new_command { + let maybe_file_tree = match args.cli { + Command::Bundle => { + let output = bundle::bundle(config, &project_root)?; + + print!("{}", output); + None + } + Command::New(new_command) => match new_command { Section { name, chapter } => { let chapter = if let Some(val) = chapter { // The user probably has not added the preceeding chapter number to the chapter @@ -61,13 +68,20 @@ fn main() -> anyhow::Result<()> { get_upwards_chapter()? }; - generate_new_section(&config, name, &project_root, &chapter)? + Some(generate_new_section( + &config, + name, + &project_root, + &chapter, + )?) } - Chapter { name } => generate_new_chapter(config, &project_root, name)?, + Chapter { name } => Some(generate_new_chapter(config, &project_root, name)?), }, }; - file_tree.materialize()?; + if let Some(file_tree) = maybe_file_tree { + file_tree.materialize()?; + } Ok(()) } |