2019-12-21 21:52:39 +00:00
|
|
|
use clap::{crate_authors, crate_description, crate_version, App, AppSettings, Arg, SubCommand};
|
2017-07-15 04:24:31 +00:00
|
|
|
|
|
|
|
pub fn build_cli() -> App<'static, 'static> {
|
2018-10-18 20:50:06 +00:00
|
|
|
App::new("zola")
|
2017-10-16 20:48:59 +00:00
|
|
|
.version(crate_version!())
|
|
|
|
.author(crate_authors!())
|
|
|
|
.about(crate_description!())
|
|
|
|
.setting(AppSettings::SubcommandRequiredElseHelp)
|
2020-01-21 19:52:24 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("root")
|
|
|
|
.short("r")
|
|
|
|
.long("root")
|
|
|
|
.takes_value(true)
|
|
|
|
.default_value(".")
|
|
|
|
.help("Directory to use as root of project")
|
|
|
|
)
|
2017-10-16 20:48:59 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("config")
|
|
|
|
.short("c")
|
|
|
|
.long("config")
|
2018-03-16 18:11:08 +00:00
|
|
|
.takes_value(true)
|
2020-05-23 09:55:45 +00:00
|
|
|
.help("Path to a config file other than config.toml in the root of project")
|
2017-07-15 04:24:31 +00:00
|
|
|
)
|
2017-10-16 20:48:59 +00:00
|
|
|
.subcommands(vec![
|
|
|
|
SubCommand::with_name("init")
|
2018-10-18 20:50:06 +00:00
|
|
|
.about("Create a new Zola project")
|
2020-06-18 19:15:46 +00:00
|
|
|
.args(&[
|
2017-10-16 20:48:59 +00:00
|
|
|
Arg::with_name("name")
|
2019-08-13 17:56:57 +00:00
|
|
|
.default_value(".")
|
2020-06-18 19:15:46 +00:00
|
|
|
.help("Name of the project. Will create a new directory with that name in the current directory"),
|
|
|
|
Arg::with_name("force")
|
|
|
|
.short("f")
|
|
|
|
.takes_value(false)
|
|
|
|
.help("Force creation of project even if directory is non-empty")
|
|
|
|
]),
|
2017-10-16 20:48:59 +00:00
|
|
|
SubCommand::with_name("build")
|
2019-01-05 10:04:12 +00:00
|
|
|
.about("Deletes the output directory if there is one and builds the site")
|
2017-10-16 20:48:59 +00:00
|
|
|
.args(&[
|
|
|
|
Arg::with_name("base_url")
|
|
|
|
.short("u")
|
|
|
|
.long("base-url")
|
2017-10-17 09:47:30 +00:00
|
|
|
.takes_value(true)
|
2017-10-16 20:48:59 +00:00
|
|
|
.help("Force the base URL to be that value (default to the one in config.toml)"),
|
2017-12-29 18:25:06 +00:00
|
|
|
Arg::with_name("output_dir")
|
|
|
|
.short("o")
|
|
|
|
.long("output-dir")
|
|
|
|
.default_value("public")
|
|
|
|
.takes_value(true)
|
|
|
|
.help("Outputs the generated site in the given path"),
|
2019-08-24 20:23:08 +00:00
|
|
|
Arg::with_name("drafts")
|
|
|
|
.long("drafts")
|
|
|
|
.takes_value(false)
|
|
|
|
.help("Include drafts when loading the site"),
|
2017-10-16 20:48:59 +00:00
|
|
|
]),
|
|
|
|
SubCommand::with_name("serve")
|
|
|
|
.about("Serve the site. Rebuild and reload on change automatically")
|
|
|
|
.args(&[
|
|
|
|
Arg::with_name("interface")
|
|
|
|
.short("i")
|
|
|
|
.long("interface")
|
|
|
|
.default_value("127.0.0.1")
|
|
|
|
.help("Interface to bind on"),
|
|
|
|
Arg::with_name("port")
|
|
|
|
.short("p")
|
|
|
|
.long("port")
|
|
|
|
.default_value("1111")
|
|
|
|
.help("Which port to use"),
|
2017-12-29 18:25:06 +00:00
|
|
|
Arg::with_name("output_dir")
|
|
|
|
.short("o")
|
|
|
|
.long("output-dir")
|
|
|
|
.default_value("public")
|
|
|
|
.takes_value(true)
|
|
|
|
.help("Outputs the generated site in the given path"),
|
2018-02-02 16:18:07 +00:00
|
|
|
Arg::with_name("base_url")
|
|
|
|
.short("u")
|
|
|
|
.long("base-url")
|
|
|
|
.default_value("127.0.0.1")
|
|
|
|
.takes_value(true)
|
|
|
|
.help("Changes the base_url"),
|
2018-11-01 22:20:35 +00:00
|
|
|
Arg::with_name("watch_only")
|
|
|
|
.long("watch-only")
|
|
|
|
.takes_value(false)
|
2019-07-04 21:42:37 +00:00
|
|
|
.help("Do not start a server, just re-build project on changes"),
|
2019-08-24 20:23:08 +00:00
|
|
|
Arg::with_name("drafts")
|
|
|
|
.long("drafts")
|
|
|
|
.takes_value(false)
|
|
|
|
.help("Include drafts when loading the site"),
|
2019-07-04 21:42:37 +00:00
|
|
|
Arg::with_name("open")
|
|
|
|
.short("O")
|
|
|
|
.long("open")
|
|
|
|
.takes_value(false)
|
|
|
|
.help("Open site in the default browser"),
|
2020-08-16 16:39:04 +00:00
|
|
|
Arg::with_name("fast")
|
|
|
|
.short("f")
|
|
|
|
.long("fast")
|
|
|
|
.takes_value(false)
|
|
|
|
.help("Only rebuild the minimum on change - useful when working on a specific page/section"),
|
2017-10-16 20:48:59 +00:00
|
|
|
]),
|
2019-05-27 12:05:07 +00:00
|
|
|
SubCommand::with_name("check")
|
|
|
|
.about("Try building the project without rendering it. Checks links")
|
2019-08-24 20:23:08 +00:00
|
|
|
.args(&[
|
|
|
|
Arg::with_name("drafts")
|
|
|
|
.long("drafts")
|
|
|
|
.takes_value(false)
|
|
|
|
.help("Include drafts when loading the site"),
|
|
|
|
])
|
2017-10-16 20:48:59 +00:00
|
|
|
])
|
2017-07-15 04:24:31 +00:00
|
|
|
}
|