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.

82 lines
3.6KB

  1. use clap::{App, AppSettings, Arg, SubCommand};
  2. pub fn build_cli() -> App<'static, 'static> {
  3. App::new("zola")
  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 Zola 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("Deletes the output directory if there is one and 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("base_path")
  33. .short("b")
  34. .long("base-path")
  35. .takes_value(true)
  36. .help("Force the base site path to a certain directory [default: the current working directory]"),
  37. Arg::with_name("output_dir")
  38. .short("o")
  39. .long("output-dir")
  40. .default_value("public")
  41. .takes_value(true)
  42. .help("Outputs the generated site in the given path"),
  43. ]),
  44. SubCommand::with_name("serve")
  45. .about("Serve the site. Rebuild and reload on change automatically")
  46. .args(&[
  47. Arg::with_name("interface")
  48. .short("i")
  49. .long("interface")
  50. .default_value("127.0.0.1")
  51. .help("Interface to bind on"),
  52. Arg::with_name("port")
  53. .short("p")
  54. .long("port")
  55. .default_value("1111")
  56. .help("Which port to use"),
  57. Arg::with_name("output_dir")
  58. .short("o")
  59. .long("output-dir")
  60. .default_value("public")
  61. .takes_value(true)
  62. .help("Outputs the generated site in the given path"),
  63. Arg::with_name("base_path")
  64. .short("b")
  65. .long("base-path")
  66. .takes_value(true)
  67. .help("Force the base site path to a certain directory [default: the current working directory]"),
  68. Arg::with_name("base_url")
  69. .short("u")
  70. .long("base-url")
  71. .default_value("127.0.0.1")
  72. .takes_value(true)
  73. .help("Changes the base_url"),
  74. Arg::with_name("watch_only")
  75. .long("watch-only")
  76. .takes_value(false)
  77. .help("Do not start a server, just re-build project on changes")
  78. ]),
  79. ])
  80. }