From d27d5e9094f0f5916266e0460ff0877ef330bd2d Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 30 Dec 2022 16:14:19 +0000 Subject: feat(list): add flag to list valid entry points --- src/main.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 1d6bdd4..acb08ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,14 +17,17 @@ const BASE: &str = "./"; #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] struct Config { + /// Simply list entry points and exit + #[clap(short, long)] + list: bool, /// Maximum substitution depth - #[clap(short, long, default_value_t = 10)] + #[clap(short, long, default_value_t = 10, value_name = "N")] depth: u32, /// Base output directory [default: './'] - #[clap(short, long)] + #[clap(short, long, value_name = "PATH")] output: Option, - /// Target files prefix - #[clap(short, long)] + /// Limit entry points to those matching the provided prefix + #[clap(short, long, value_name = "PREFIX")] target: Option, /// Input files input: Vec, @@ -122,10 +125,7 @@ fn write_to_file( fs::create_dir_all(path.parent().unwrap())?; fs::write(path, content)?; } else { - eprintln!( - "Absolute paths not supported: {}", - path.to_string_lossy() - ) + eprintln!("Absolute paths not supported: {}", path.display()) } Ok(()) } @@ -186,7 +186,14 @@ fn main() -> Result<()> { } } ); - build(&config.output, &blocks, config.depth); + if config.list { + blocks.keys().for_each(|k| match k { + Key::Entry(s) => println!("{}", s.display()), + Key::Macro(_) => {} + }); + } else { + build(&config.output, &blocks, config.depth); + } pandoc } ) -- cgit v1.2.3