You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
712B

  1. use std::env;
  2. use std::path::PathBuf;
  3. use errors::Result;
  4. use site::Site;
  5. use crate::console;
  6. pub fn check(
  7. config_file: &str,
  8. base_path: Option<&str>,
  9. base_url: Option<&str>,
  10. include_drafts: bool,
  11. ) -> Result<()> {
  12. let bp = base_path.map(PathBuf::from).unwrap_or_else(|| env::current_dir().unwrap());
  13. let mut site = Site::new(bp, config_file)?;
  14. // Force the checking of external links
  15. site.config.enable_check_mode();
  16. if let Some(b) = base_url {
  17. site.set_base_url(b.to_string());
  18. }
  19. if include_drafts {
  20. site.include_drafts();
  21. }
  22. site.load()?;
  23. console::check_site_summary(&site);
  24. console::warn_about_ignored_pages(&site);
  25. Ok(())
  26. }