123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- extern crate clap;
-
- use clap::{App, Arg};
-
- use std::env;
-
- fn main() {
- let matches = App::new("casaubon")
- .version("0.3.2")
- .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" {
- casaubon::build(
- include_drafts,
- &env::current_dir().expect("Can't read current directory"),
- );
- } else if command == "new" {
- casaubon::new(
- matches.value_of("name").unwrap(),
- &env::current_dir().expect("Can't read current directory"),
- );
- } else if command == "watch" {
- casaubon::build(
- include_drafts,
- &env::current_dir().expect("Can't read current directory"),
- );
- casaubon::watch(
- include_drafts,
- &env::current_dir().expect("Can't read current directory"),
- )
- .expect("Error while watching posts directory");
- }
- }
|