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.

60 lines
2.4KB

  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. Arg::with_name("output_dir")
  31. .short("o")
  32. .long("output-dir")
  33. .default_value("public")
  34. .takes_value(true)
  35. .help("Outputs the generated site in the given path"),
  36. ]),
  37. SubCommand::with_name("serve")
  38. .about("Serve the site. Rebuild and reload on change automatically")
  39. .args(&[
  40. Arg::with_name("interface")
  41. .short("i")
  42. .long("interface")
  43. .default_value("127.0.0.1")
  44. .help("Interface to bind on"),
  45. Arg::with_name("port")
  46. .short("p")
  47. .long("port")
  48. .default_value("1111")
  49. .help("Which port to use"),
  50. Arg::with_name("output_dir")
  51. .short("o")
  52. .long("output-dir")
  53. .default_value("public")
  54. .takes_value(true)
  55. .help("Outputs the generated site in the given path"),
  56. ]),
  57. ])
  58. }