A static site generator written in Rust
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

main.rs 1.4KB

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