A static site generator written in Rust
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.

main.rs 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. extern crate clap;
  2. extern crate comrak;
  3. extern crate fs_extra;
  4. #[macro_use]
  5. extern crate lazy_static;
  6. extern crate notify;
  7. extern crate regex;
  8. extern crate toml;
  9. extern crate uuid;
  10. use clap::{App, Arg};
  11. use commands::{build, new, watch};
  12. mod commands;
  13. mod config;
  14. mod post;
  15. mod render;
  16. mod write;
  17. fn main() {
  18. let matches = App::new("casaubon")
  19. .version("0.1.0")
  20. .author("Dylan Baker")
  21. .about("Highly opinionated static site generator")
  22. .arg(
  23. Arg::with_name("command")
  24. .required(true)
  25. .possible_values(&["build", "new", "watch"])
  26. .index(1),
  27. )
  28. .arg(Arg::with_name("drafts").short("d").long("drafts"))
  29. .arg(
  30. Arg::with_name("name")
  31. .required_if("command", "new")
  32. .index(2),
  33. )
  34. .get_matches();
  35. let include_drafts = match matches.occurrences_of("drafts") {
  36. 0 => false,
  37. 1 => true,
  38. _ => true,
  39. };
  40. let command = matches.value_of("command").unwrap();
  41. if command == "build" {
  42. build(include_drafts);
  43. } else if command == "new" {
  44. new(&matches.value_of("name").unwrap());
  45. } else if command == "watch" {
  46. build(include_drafts);
  47. watch(include_drafts).expect("Error while watching posts directory");
  48. }
  49. }