A static site generator written in Rust
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

main.rs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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("tlon")
  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. ).arg(Arg::with_name("drafts").short("d").long("drafts"))
  28. .arg(
  29. Arg::with_name("name")
  30. .required_if("command", "new")
  31. .index(2),
  32. ).get_matches();
  33. let include_drafts = match matches.occurrences_of("drafts") {
  34. 0 => false,
  35. 1 => true,
  36. _ => true,
  37. };
  38. let command = matches.value_of("command").unwrap();
  39. if command == "build" {
  40. build(include_drafts);
  41. } else if command == "new" {
  42. new(&matches.value_of("name").unwrap());
  43. } else if command == "watch" {
  44. build(include_drafts);
  45. watch(include_drafts).expect("Error while watching posts directory");
  46. }
  47. }