You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3KB

  1. // `error_chain!` can recurse deeply
  2. #![recursion_limit = "1024"]
  3. #[macro_use] extern crate clap;
  4. #[macro_use] extern crate error_chain;
  5. extern crate toml;
  6. mod config;
  7. mod errors;
  8. mod cmd;
  9. use config::Config;
  10. fn get_config() -> Config {
  11. match Config::from_file("config.toml") {
  12. Ok(c) => c,
  13. Err(e) => {
  14. println!("Error: {}", e);
  15. ::std::process::exit(1);
  16. }
  17. }
  18. }
  19. fn main() {
  20. let matches = clap_app!(myapp =>
  21. (version: crate_version!())
  22. (author: "Vincent Prouillet")
  23. (about: "Static site generator")
  24. (@setting SubcommandRequiredElseHelp)
  25. (@subcommand new =>
  26. (about: "Create a new Gutenberg project")
  27. (@arg name: +required "Name of the project. Will create a directory with that name in the current directory")
  28. )
  29. ).get_matches();
  30. match matches.subcommand() {
  31. ("new", Some(matches)) => {
  32. match cmd::create_new_project(matches.value_of("name").unwrap()) {
  33. Ok(()) => {
  34. println!("Project created");
  35. },
  36. Err(e) => {
  37. println!("Error: {}", e);
  38. ::std::process::exit(1);
  39. },
  40. };
  41. },
  42. _ => unreachable!(),
  43. }
  44. }