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.

93 lines
4.1KB

  1. use clap::{crate_authors, crate_description, crate_version, 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. .default_value(".")
  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("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. Arg::with_name("drafts")
  39. .long("drafts")
  40. .takes_value(false)
  41. .help("Include drafts when loading the site"),
  42. ]),
  43. SubCommand::with_name("serve")
  44. .about("Serve the site. Rebuild and reload on change automatically")
  45. .args(&[
  46. Arg::with_name("interface")
  47. .short("i")
  48. .long("interface")
  49. .default_value("127.0.0.1")
  50. .help("Interface to bind on"),
  51. Arg::with_name("port")
  52. .short("p")
  53. .long("port")
  54. .default_value("1111")
  55. .help("Which port to use"),
  56. Arg::with_name("output_dir")
  57. .short("o")
  58. .long("output-dir")
  59. .default_value("public")
  60. .takes_value(true)
  61. .help("Outputs the generated site in the given path"),
  62. Arg::with_name("base_url")
  63. .short("u")
  64. .long("base-url")
  65. .default_value("127.0.0.1")
  66. .takes_value(true)
  67. .help("Changes the base_url"),
  68. Arg::with_name("watch_only")
  69. .long("watch-only")
  70. .takes_value(false)
  71. .help("Do not start a server, just re-build project on changes"),
  72. Arg::with_name("drafts")
  73. .long("drafts")
  74. .takes_value(false)
  75. .help("Include drafts when loading the site"),
  76. Arg::with_name("open")
  77. .short("O")
  78. .long("open")
  79. .takes_value(false)
  80. .help("Open site in the default browser"),
  81. ]),
  82. SubCommand::with_name("check")
  83. .about("Try building the project without rendering it. Checks links")
  84. .args(&[
  85. Arg::with_name("drafts")
  86. .long("drafts")
  87. .takes_value(false)
  88. .help("Include drafts when loading the site"),
  89. ])
  90. ])
  91. }