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.

68 lines
2.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. .default_value("config.toml")
  13. .takes_value(true)
  14. .help("Path to a config file other than config.toml")
  15. )
  16. .subcommands(vec![
  17. SubCommand::with_name("init")
  18. .about("Create a new Gutenberg project")
  19. .arg(
  20. Arg::with_name("name")
  21. .required(true)
  22. .help("Name of the project. Will create a new directory with that name in the current directory")
  23. ),
  24. SubCommand::with_name("build")
  25. .about("Builds the site")
  26. .args(&[
  27. Arg::with_name("base_url")
  28. .short("u")
  29. .long("base-url")
  30. .takes_value(true)
  31. .help("Force the base URL to be that value (default to the one in config.toml)"),
  32. Arg::with_name("output_dir")
  33. .short("o")
  34. .long("output-dir")
  35. .default_value("public")
  36. .takes_value(true)
  37. .help("Outputs the generated site in the given path"),
  38. ]),
  39. SubCommand::with_name("serve")
  40. .about("Serve the site. Rebuild and reload on change automatically")
  41. .args(&[
  42. Arg::with_name("interface")
  43. .short("i")
  44. .long("interface")
  45. .default_value("127.0.0.1")
  46. .help("Interface to bind on"),
  47. Arg::with_name("port")
  48. .short("p")
  49. .long("port")
  50. .default_value("1111")
  51. .help("Which port to use"),
  52. Arg::with_name("output_dir")
  53. .short("o")
  54. .long("output-dir")
  55. .default_value("public")
  56. .takes_value(true)
  57. .help("Outputs the generated site in the given path"),
  58. Arg::with_name("base_url")
  59. .short("u")
  60. .long("base-url")
  61. .default_value("127.0.0.1")
  62. .takes_value(true)
  63. .help("Changes the base_url"),
  64. ]),
  65. ])
  66. }