diff options
Diffstat (limited to 'src/bin/riki.rs')
-rw-r--r-- | src/bin/riki.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/bin/riki.rs b/src/bin/riki.rs index c1f9e4b..131326b 100644 --- a/src/bin/riki.rs +++ b/src/bin/riki.rs @@ -52,6 +52,7 @@ fn real_main() -> Result<(), RikiError> { Command::Timestamps(cmd) => cmd.run()?, Command::ParseDate(cmd) => cmd.run()?, Command::PageSpec(cmd) => cmd.run()?, + Command::Links(cmd) => cmd.run()?, } } @@ -77,6 +78,7 @@ enum Command { Timestamps(Timestamps), ParseDate(ParseDate), PageSpec(PageSpec), + Links(Links), } /// Build the site. @@ -227,6 +229,7 @@ impl PageSpec { site.process()?; let pagespec = pagespec::PageSpec::new(&self.path, &self.pagespec)?; + debug!("pagespec: {:#?}", pagespec); for page in site.markdown_pages() { let path = page.meta().path(); @@ -247,3 +250,33 @@ impl PageSpec { Ok(()) } } + +/// List links in the pages listed on the command line. +#[derive(Parser)] +struct Links { + /// Directory where source files are. + srcdir: PathBuf, + + /// Path to pages whose links are to be listed. + pages: Vec<PathBuf>, +} + +impl Links { + fn run(&self) -> Result<(), RikiError> { + let srcdir = canonicalize(&self.srcdir)?; + let mut site = Site::new(&srcdir, &PathBuf::from("/tmp")); + site.scan()?; + site.process()?; + + for path in self.pages.iter() { + if let Some(page) = site.page(path) { + println!("page: {:?}", page.meta().path().display()); + for path in page.meta().links_to() { + println!(" {}", path.display()); + } + } + } + + Ok(()) + } +} |