add: recursive flag
This commit is contained in:
parent
5b2c3e969c
commit
c798e387bd
2 changed files with 31 additions and 2 deletions
13
src/main.rs
13
src/main.rs
|
|
@ -2,7 +2,7 @@ use std::env;
|
|||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use typssg::compile_article;
|
||||
use typssg::{compile_article, compile_all};
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
|
|
@ -11,6 +11,9 @@ struct Args {
|
|||
|
||||
#[arg(long)]
|
||||
prepend: Option<PathBuf>,
|
||||
|
||||
#[arg(short)]
|
||||
recursive: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -21,7 +24,13 @@ fn main() {
|
|||
|
||||
let args = Args::parse();
|
||||
|
||||
if let Err(e) = compile_article(&args.dir, &args.prepend) {
|
||||
let result = if args.recursive {
|
||||
compile_all(&args.dir, &args.prepend)
|
||||
} else {
|
||||
compile_article(&args.dir, &args.prepend)
|
||||
};
|
||||
|
||||
if let Err(e) = result {
|
||||
eprintln!("{e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue