A static site generator written in Rust
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

main.rs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 entry;
  16. mod page;
  17. mod post;
  18. fn main() {
  19. let matches = App::new("casaubon")
  20. .version("0.1.1")
  21. .author("Dylan Baker")
  22. .about("Highly opinionated static site generator")
  23. .arg(
  24. Arg::with_name("command")
  25. .required(true)
  26. .possible_values(&["build", "new", "watch"])
  27. .index(1),
  28. )
  29. .arg(Arg::with_name("drafts").short("d").long("drafts"))
  30. .arg(
  31. Arg::with_name("name")
  32. .required_if("command", "new")
  33. .index(2),
  34. )
  35. .get_matches();
  36. let include_drafts = match matches.occurrences_of("drafts") {
  37. 0 => false,
  38. 1 => true,
  39. _ => true,
  40. };
  41. let command = matches.value_of("command").unwrap();
  42. if command == "build" {
  43. build(include_drafts);
  44. } else if command == "new" {
  45. new(&matches.value_of("name").unwrap());
  46. } else if command == "watch" {
  47. build(include_drafts);
  48. watch(include_drafts).expect("Error while watching posts directory");
  49. }
  50. }