parent
bfbc16d3ad
commit
974ae167a8
|
@ -20,8 +20,8 @@ Register-ArgumentCompleter -Native -CommandName 'zola' -ScriptBlock {
|
||||||
|
|
||||||
$completions = @(switch ($command) {
|
$completions = @(switch ($command) {
|
||||||
'zola' {
|
'zola' {
|
||||||
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to a config file other than config.toml')
|
[CompletionResult]::new('-c', 'c', [CompletionResultType]::ParameterName, 'Path to a config file other than config.toml in the root of project')
|
||||||
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to a config file other than config.toml')
|
[CompletionResult]::new('--config', 'config', [CompletionResultType]::ParameterName, 'Path to a config file other than config.toml in the root of project')
|
||||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Prints help information')
|
||||||
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints version information')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
complete -c zola -n "__fish_use_subcommand" -s c -l config -d 'Path to a config file other than config.toml'
|
complete -c zola -n "__fish_use_subcommand" -s c -l config -d 'Path to a config file other than config.toml in the root of project'
|
||||||
complete -c zola -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
|
complete -c zola -n "__fish_use_subcommand" -s h -l help -d 'Prints help information'
|
||||||
complete -c zola -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
|
complete -c zola -n "__fish_use_subcommand" -s V -l version -d 'Prints version information'
|
||||||
complete -c zola -n "__fish_use_subcommand" -f -a "init" -d 'Create a new Zola project'
|
complete -c zola -n "__fish_use_subcommand" -f -a "init" -d 'Create a new Zola project'
|
||||||
|
|
|
@ -7,11 +7,11 @@ use std::path::Path;
|
||||||
|
|
||||||
/// Get and parse the config.
|
/// Get and parse the config.
|
||||||
/// If it doesn't succeed, exit
|
/// If it doesn't succeed, exit
|
||||||
pub fn get_config(path: &Path, filename: &str) -> Config {
|
pub fn get_config(filename: &Path) -> Config {
|
||||||
match Config::from_file(path.join(filename)) {
|
match Config::from_file(filename) {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Failed to load {}", filename);
|
println!("Failed to load {}", filename.display());
|
||||||
println!("Error: {}", e);
|
println!("Error: {}", e);
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl Theme {
|
||||||
let content = read_file_with_error(
|
let content = read_file_with_error(
|
||||||
path,
|
path,
|
||||||
"No `theme.toml` file found. \
|
"No `theme.toml` file found. \
|
||||||
Is the `theme` defined in your `config.toml present in the `themes` directory \
|
Is the `theme` defined in your `config.toml` present in the `themes` directory \
|
||||||
and does it have a `theme.toml` inside?",
|
and does it have a `theme.toml` inside?",
|
||||||
)?;
|
)?;
|
||||||
Theme::parse(&content)
|
Theme::parse(&content)
|
||||||
|
|
|
@ -20,7 +20,8 @@ macro_rules! load_and_build_site {
|
||||||
dir::copy(&path, &$tmp_dir, &options).unwrap();
|
dir::copy(&path, &$tmp_dir, &options).unwrap();
|
||||||
|
|
||||||
let site_path = $tmp_dir.path().join($site);
|
let site_path = $tmp_dir.path().join($site);
|
||||||
let mut site = Site::new(&site_path, "config.toml").unwrap();
|
let config_file = site_path.join("config.toml");
|
||||||
|
let mut site = Site::new(&site_path, &config_file).unwrap();
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
let public = &site_path.join("public");
|
let public = &site_path.join("public");
|
||||||
site.set_output_path(&public);
|
site.set_output_path(&public);
|
||||||
|
|
|
@ -11,7 +11,8 @@ fn bench_loading_small_blog(b: &mut test::Bencher) {
|
||||||
let mut path = env::current_dir().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
path.push("benches");
|
path.push("benches");
|
||||||
path.push("small-blog");
|
path.push("small-blog");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
|
|
||||||
b.iter(|| site.load().unwrap());
|
b.iter(|| site.load().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -21,7 +22,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
let mut path = env::current_dir().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
path.push("benches");
|
path.push("benches");
|
||||||
path.push("small-blog");
|
path.push("small-blog");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.config.highlight_code = true;
|
site.config.highlight_code = true;
|
||||||
|
|
||||||
b.iter(|| site.load().unwrap());
|
b.iter(|| site.load().unwrap());
|
||||||
|
@ -32,7 +34,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("medium-blog");
|
// path.push("medium-blog");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
//}
|
//}
|
||||||
|
@ -42,7 +45,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("medium-blog");
|
// path.push("medium-blog");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
// site.config.highlight_code = true;
|
// site.config.highlight_code = true;
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
|
@ -53,7 +57,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("big-blog");
|
// path.push("big-blog");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
//}
|
//}
|
||||||
|
@ -63,7 +68,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("big-blog");
|
// path.push("big-blog");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
// site.config.highlight_code = true;
|
// site.config.highlight_code = true;
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
|
@ -74,7 +80,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("huge-blog");
|
// path.push("huge-blog");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
//}
|
//}
|
||||||
|
@ -84,7 +91,8 @@ fn bench_loading_small_blog_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("huge-blog");
|
// path.push("huge-blog");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
// site.config.highlight_code = true;
|
// site.config.highlight_code = true;
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
|
@ -95,7 +103,8 @@ fn bench_loading_small_kb(b: &mut test::Bencher) {
|
||||||
let mut path = env::current_dir().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
path.push("benches");
|
path.push("benches");
|
||||||
path.push("small-kb");
|
path.push("small-kb");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
|
|
||||||
b.iter(|| site.load().unwrap());
|
b.iter(|| site.load().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -105,7 +114,8 @@ fn bench_loading_small_kb_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
let mut path = env::current_dir().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
path.push("benches");
|
path.push("benches");
|
||||||
path.push("small-kb");
|
path.push("small-kb");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.config.highlight_code = true;
|
site.config.highlight_code = true;
|
||||||
|
|
||||||
b.iter(|| site.load().unwrap());
|
b.iter(|| site.load().unwrap());
|
||||||
|
@ -116,7 +126,8 @@ fn bench_loading_small_kb_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("medium-kb");
|
// path.push("medium-kb");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
//}
|
//}
|
||||||
|
@ -126,7 +137,8 @@ fn bench_loading_small_kb_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("medium-kb");
|
// path.push("medium-kb");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
// site.config.highlight_code = Some(true);
|
// site.config.highlight_code = Some(true);
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
|
@ -137,7 +149,8 @@ fn bench_loading_small_kb_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("huge-kb");
|
// path.push("huge-kb");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
//}
|
//}
|
||||||
|
@ -147,7 +160,8 @@ fn bench_loading_small_kb_with_syntax_highlighting(b: &mut test::Bencher) {
|
||||||
// let mut path = env::current_dir().unwrap().to_path_buf();
|
// let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
// path.push("benches");
|
// path.push("benches");
|
||||||
// path.push("huge-kb");
|
// path.push("huge-kb");
|
||||||
// let mut site = Site::new(&path, "config.toml").unwrap();
|
// let config_file = path.join("config.toml");
|
||||||
|
// let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
// site.config.highlight_code = Some(true);
|
// site.config.highlight_code = Some(true);
|
||||||
//
|
//
|
||||||
// b.iter(|| site.load().unwrap());
|
// b.iter(|| site.load().unwrap());
|
||||||
|
|
|
@ -11,7 +11,8 @@ fn setup_site(name: &str) -> Site {
|
||||||
let mut path = env::current_dir().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().to_path_buf();
|
||||||
path.push("benches");
|
path.push("benches");
|
||||||
path.push(name);
|
path.push(name);
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
site
|
site
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,10 @@ impl<'a> SerializedTaxonomyItem<'a> {
|
||||||
impl Site {
|
impl Site {
|
||||||
/// Parse a site at the given path. Defaults to the current dir
|
/// Parse a site at the given path. Defaults to the current dir
|
||||||
/// Passing in a path is used in tests and when --root argument is passed
|
/// Passing in a path is used in tests and when --root argument is passed
|
||||||
pub fn new<P: AsRef<Path>>(path: P, config_file: &str) -> Result<Site> {
|
pub fn new<P: AsRef<Path>, P2: AsRef<Path>>(path: P, config_file: P2) -> Result<Site> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let mut config = get_config(path, config_file);
|
let config_file = config_file.as_ref();
|
||||||
|
let mut config = get_config(config_file);
|
||||||
config.load_extra_syntaxes(path)?;
|
config.load_extra_syntaxes(path)?;
|
||||||
|
|
||||||
let tpl_glob =
|
let tpl_glob =
|
||||||
|
|
|
@ -38,7 +38,8 @@ macro_rules! file_contains {
|
||||||
pub fn build_site(name: &str) -> (Site, TempDir, PathBuf) {
|
pub fn build_site(name: &str) -> (Site, TempDir, PathBuf) {
|
||||||
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
||||||
path.push(name);
|
path.push(name);
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
let tmp_dir = tempdir().expect("create temp dir");
|
let tmp_dir = tempdir().expect("create temp dir");
|
||||||
let public = &tmp_dir.path().join("public");
|
let public = &tmp_dir.path().join("public");
|
||||||
|
@ -54,7 +55,8 @@ where
|
||||||
{
|
{
|
||||||
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
||||||
path.push(name);
|
path.push(name);
|
||||||
let site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let site = Site::new(&path, &config_file).unwrap();
|
||||||
let (mut site, needs_loading) = setup_cb(site);
|
let (mut site, needs_loading) = setup_cb(site);
|
||||||
if needs_loading {
|
if needs_loading {
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
|
|
|
@ -13,7 +13,8 @@ use site::Site;
|
||||||
fn can_parse_site() {
|
fn can_parse_site() {
|
||||||
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
||||||
path.push("test_site");
|
path.push("test_site");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
let library = site.library.read().unwrap();
|
let library = site.library.read().unwrap();
|
||||||
|
|
||||||
|
@ -628,7 +629,8 @@ fn can_build_with_extra_syntaxes() {
|
||||||
fn can_apply_page_templates() {
|
fn can_apply_page_templates() {
|
||||||
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
||||||
path.push("test_site");
|
path.push("test_site");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
|
|
||||||
let template_path = path.join("content").join("applying_page_template");
|
let template_path = path.join("content").join("applying_page_template");
|
||||||
|
|
|
@ -9,7 +9,8 @@ use site::Site;
|
||||||
fn can_parse_multilingual_site() {
|
fn can_parse_multilingual_site() {
|
||||||
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
let mut path = env::current_dir().unwrap().parent().unwrap().parent().unwrap().to_path_buf();
|
||||||
path.push("test_site_i18n");
|
path.push("test_site_i18n");
|
||||||
let mut site = Site::new(&path, "config.toml").unwrap();
|
let config_file = path.join("config.toml");
|
||||||
|
let mut site = Site::new(&path, &config_file).unwrap();
|
||||||
site.load().unwrap();
|
site.load().unwrap();
|
||||||
|
|
||||||
let library = site.library.read().unwrap();
|
let library = site.library.read().unwrap();
|
||||||
|
|
|
@ -18,9 +18,8 @@ pub fn build_cli() -> App<'static, 'static> {
|
||||||
Arg::with_name("config")
|
Arg::with_name("config")
|
||||||
.short("c")
|
.short("c")
|
||||||
.long("config")
|
.long("config")
|
||||||
.default_value("config.toml")
|
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Path to a config file other than config.toml")
|
.help("Path to a config file other than config.toml in the root of project")
|
||||||
)
|
)
|
||||||
.subcommands(vec![
|
.subcommands(vec![
|
||||||
SubCommand::with_name("init")
|
SubCommand::with_name("init")
|
||||||
|
|
|
@ -7,9 +7,9 @@ use crate::console;
|
||||||
|
|
||||||
pub fn build(
|
pub fn build(
|
||||||
root_dir: &Path,
|
root_dir: &Path,
|
||||||
config_file: &str,
|
config_file: &Path,
|
||||||
base_url: Option<&str>,
|
base_url: Option<&str>,
|
||||||
output_dir: &str,
|
output_dir: &Path,
|
||||||
include_drafts: bool,
|
include_drafts: bool,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut site = Site::new(root_dir, config_file)?;
|
let mut site = Site::new(root_dir, config_file)?;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::console;
|
||||||
|
|
||||||
pub fn check(
|
pub fn check(
|
||||||
root_dir: &Path,
|
root_dir: &Path,
|
||||||
config_file: &str,
|
config_file: &Path,
|
||||||
base_path: Option<&str>,
|
base_path: Option<&str>,
|
||||||
base_url: Option<&str>,
|
base_url: Option<&str>,
|
||||||
include_drafts: bool,
|
include_drafts: bool,
|
||||||
|
|
|
@ -161,9 +161,9 @@ fn create_new_site(
|
||||||
root_dir: &Path,
|
root_dir: &Path,
|
||||||
interface: &str,
|
interface: &str,
|
||||||
port: u16,
|
port: u16,
|
||||||
output_dir: &str,
|
output_dir: &Path,
|
||||||
base_url: &str,
|
base_url: &str,
|
||||||
config_file: &str,
|
config_file: &Path,
|
||||||
include_drafts: bool,
|
include_drafts: bool,
|
||||||
) -> Result<(Site, String)> {
|
) -> Result<(Site, String)> {
|
||||||
let mut site = Site::new(root_dir, config_file)?;
|
let mut site = Site::new(root_dir, config_file)?;
|
||||||
|
@ -194,9 +194,9 @@ pub fn serve(
|
||||||
root_dir: &Path,
|
root_dir: &Path,
|
||||||
interface: &str,
|
interface: &str,
|
||||||
port: u16,
|
port: u16,
|
||||||
output_dir: &str,
|
output_dir: &Path,
|
||||||
base_url: &str,
|
base_url: &str,
|
||||||
config_file: &str,
|
config_file: &Path,
|
||||||
watch_only: bool,
|
watch_only: bool,
|
||||||
open: bool,
|
open: bool,
|
||||||
include_drafts: bool,
|
include_drafts: bool,
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -16,7 +16,10 @@ fn main() {
|
||||||
"." => env::current_dir().unwrap(),
|
"." => env::current_dir().unwrap(),
|
||||||
path => PathBuf::from(path),
|
path => PathBuf::from(path),
|
||||||
};
|
};
|
||||||
let config_file = matches.value_of("config").unwrap();
|
let config_file = match matches.value_of("config") {
|
||||||
|
Some(path) => PathBuf::from(path),
|
||||||
|
None => root_dir.join("config.toml"),
|
||||||
|
};
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
("init", Some(matches)) => {
|
("init", Some(matches)) => {
|
||||||
|
@ -31,12 +34,12 @@ fn main() {
|
||||||
("build", Some(matches)) => {
|
("build", Some(matches)) => {
|
||||||
console::info("Building site...");
|
console::info("Building site...");
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let output_dir = matches.value_of("output_dir").unwrap();
|
let output_dir = PathBuf::from(matches.value_of("output_dir").unwrap());
|
||||||
match cmd::build(
|
match cmd::build(
|
||||||
&root_dir,
|
&root_dir,
|
||||||
config_file,
|
&config_file,
|
||||||
matches.value_of("base_url"),
|
matches.value_of("base_url"),
|
||||||
output_dir,
|
&output_dir,
|
||||||
matches.is_present("drafts"),
|
matches.is_present("drafts"),
|
||||||
) {
|
) {
|
||||||
Ok(()) => console::report_elapsed_time(start),
|
Ok(()) => console::report_elapsed_time(start),
|
||||||
|
@ -73,16 +76,16 @@ fn main() {
|
||||||
::std::process::exit(1);
|
::std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let output_dir = matches.value_of("output_dir").unwrap();
|
let output_dir = PathBuf::from(matches.value_of("output_dir").unwrap());
|
||||||
let base_url = matches.value_of("base_url").unwrap();
|
let base_url = matches.value_of("base_url").unwrap();
|
||||||
console::info("Building site...");
|
console::info("Building site...");
|
||||||
match cmd::serve(
|
match cmd::serve(
|
||||||
&root_dir,
|
&root_dir,
|
||||||
interface,
|
interface,
|
||||||
port,
|
port,
|
||||||
output_dir,
|
&output_dir,
|
||||||
base_url,
|
base_url,
|
||||||
config_file,
|
&config_file,
|
||||||
watch_only,
|
watch_only,
|
||||||
open,
|
open,
|
||||||
include_drafts,
|
include_drafts,
|
||||||
|
@ -99,7 +102,7 @@ fn main() {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
match cmd::check(
|
match cmd::check(
|
||||||
&root_dir,
|
&root_dir,
|
||||||
config_file,
|
&config_file,
|
||||||
matches.value_of("base_path"),
|
matches.value_of("base_path"),
|
||||||
matches.value_of("base_url"),
|
matches.value_of("base_url"),
|
||||||
matches.is_present("drafts"),
|
matches.is_present("drafts"),
|
||||||
|
|
Loading…
Reference in a new issue