1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- extern crate clap;
- extern crate comrak;
- extern crate fs_extra;
- #[macro_use]
- extern crate lazy_static;
- extern crate notify;
- extern crate regex;
- extern crate toml;
- extern crate uuid;
-
- use clap::{App, Arg};
-
- use commands::{build, new, watch};
-
- mod commands;
- mod config;
- mod post;
- mod render;
- mod write;
-
- fn main() {
- let matches = App::new("tlon")
- .version("0.1.0")
- .author("Dylan Baker")
- .about("Highly opinionated static site generator")
- .arg(
- Arg::with_name("command")
- .required(true)
- .possible_values(&["build", "new", "watch"])
- .index(1),
- ).arg(Arg::with_name("drafts").short("d").long("drafts"))
- .arg(
- Arg::with_name("name")
- .required_if("command", "new")
- .index(2),
- ).get_matches();
-
- let include_drafts = match matches.occurrences_of("drafts") {
- 0 => false,
- 1 => true,
- _ => true,
- };
-
- let command = matches.value_of("command").unwrap();
- if command == "build" {
- build(include_drafts);
- } else if command == "new" {
- new(&matches.value_of("name").unwrap());
- } else if command == "watch" {
- build(include_drafts);
- watch(include_drafts).expect("Error while watching posts directory");
- }
- }
|