aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-09-16 18:41:51 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-09-16 18:41:51 +0200
commitb59cc730fdbcc81752d6c9b23ac00a3b0aff1c8a (patch)
tree9be6b3004c259d8afe08dce170fa04c6d3265f35 /src/main.rs
parentchore(references): Add testing data (diff)
downloadlpm-b59cc730fdbcc81752d6c9b23ac00a3b0aff1c8a.zip
feat(bundle): Support bundling a document into one TeX file
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs26
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(())
}