diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 25 |
1 files changed, 16 insertions, 9 deletions
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 = "./"; | |||
| 17 | #[derive(Parser, Debug)] | 17 | #[derive(Parser, Debug)] |
| 18 | #[clap(author, version, about, long_about = None)] | 18 | #[clap(author, version, about, long_about = None)] |
| 19 | struct Config { | 19 | struct Config { |
| 20 | /// Simply list entry points and exit | ||
| 21 | #[clap(short, long)] | ||
| 22 | list: bool, | ||
| 20 | /// Maximum substitution depth | 23 | /// Maximum substitution depth |
| 21 | #[clap(short, long, default_value_t = 10)] | 24 | #[clap(short, long, default_value_t = 10, value_name = "N")] |
| 22 | depth: u32, | 25 | depth: u32, |
| 23 | /// Base output directory [default: './'] | 26 | /// Base output directory [default: './'] |
| 24 | #[clap(short, long)] | 27 | #[clap(short, long, value_name = "PATH")] |
| 25 | output: Option<PathBuf>, | 28 | output: Option<PathBuf>, |
| 26 | /// Target files prefix | 29 | /// Limit entry points to those matching the provided prefix |
| 27 | #[clap(short, long)] | 30 | #[clap(short, long, value_name = "PREFIX")] |
| 28 | target: Option<PathBuf>, | 31 | target: Option<PathBuf>, |
| 29 | /// Input files | 32 | /// Input files |
| 30 | input: Vec<PathBuf>, | 33 | input: Vec<PathBuf>, |
| @@ -122,10 +125,7 @@ fn write_to_file( | |||
| 122 | fs::create_dir_all(path.parent().unwrap())?; | 125 | fs::create_dir_all(path.parent().unwrap())?; |
| 123 | fs::write(path, content)?; | 126 | fs::write(path, content)?; |
| 124 | } else { | 127 | } else { |
| 125 | eprintln!( | 128 | eprintln!("Absolute paths not supported: {}", path.display()) |
| 126 | "Absolute paths not supported: {}", | ||
| 127 | path.to_string_lossy() | ||
| 128 | ) | ||
| 129 | } | 129 | } |
| 130 | Ok(()) | 130 | Ok(()) |
| 131 | } | 131 | } |
| @@ -186,7 +186,14 @@ fn main() -> Result<()> { | |||
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | ); | 188 | ); |
| 189 | build(&config.output, &blocks, config.depth); | 189 | if config.list { |
| 190 | blocks.keys().for_each(|k| match k { | ||
| 191 | Key::Entry(s) => println!("{}", s.display()), | ||
| 192 | Key::Macro(_) => {} | ||
| 193 | }); | ||
| 194 | } else { | ||
| 195 | build(&config.output, &blocks, config.depth); | ||
| 196 | } | ||
| 190 | pandoc | 197 | pandoc |
| 191 | } | 198 | } |
| 192 | ) | 199 | ) |
