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.

48 lines
1.8KB

  1. use clap::{App, AppSettings, Arg, SubCommand};
  2. pub fn build_cli() -> App<'static, 'static> {
  3. App::new("gutenberg")
  4. .version(crate_version!())
  5. .author(crate_authors!())
  6. .about(crate_description!())
  7. .setting(AppSettings::SubcommandRequiredElseHelp)
  8. .arg(
  9. Arg::with_name("config")
  10. .short("c")
  11. .long("config")
  12. .help("Path to a config file other than config.toml")
  13. )
  14. .subcommands(vec![
  15. SubCommand::with_name("init")
  16. .about("Create a new Gutenberg project")
  17. .arg(
  18. Arg::with_name("name")
  19. .required(true)
  20. .help("Name of the project. Will create a new directory with that name in the current directory")
  21. ),
  22. SubCommand::with_name("build")
  23. .about("Builds the site")
  24. .args(&[
  25. Arg::with_name("base_url")
  26. .short("u")
  27. .long("base-url")
  28. .takes_value(true)
  29. .help("Force the base URL to be that value (default to the one in config.toml)"),
  30. ]),
  31. SubCommand::with_name("serve")
  32. .about("Serve the site. Rebuild and reload on change automatically")
  33. .args(&[
  34. Arg::with_name("interface")
  35. .short("i")
  36. .long("interface")
  37. .default_value("127.0.0.1")
  38. .help("Interface to bind on"),
  39. Arg::with_name("port")
  40. .short("p")
  41. .long("port")
  42. .default_value("1111")
  43. .help("Which port to use"),
  44. ]),
  45. ])
  46. }