Centralize configuration and add some new config (#494)

Ideally, if someone could review the idea in [this comment](https://github.com/Plume-org/Plume/issues/273#issuecomment-474982184), I'd like to add the implementation to this pr too
This commit is contained in:
fdb-hiroshima
2019-03-21 10:30:33 +01:00
committed by Baptiste Gelez
parent b945d1f602
commit 65bb50e88f
12 changed files with 117 additions and 89 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
use clap::{App, Arg, ArgMatches, SubCommand};
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
use plume_models::{posts::Post, schema::posts, search::Searcher, Connection};
use plume_models::{posts::Post, schema::posts, search::Searcher, Connection, CONFIG};
use std::fs::{read_dir, remove_file};
use std::io::ErrorKind;
use std::path::Path;
@@ -64,9 +64,9 @@ pub fn run<'a>(args: &ArgMatches<'a>, conn: &Connection) {
}
fn init<'a>(args: &ArgMatches<'a>, conn: &Connection) {
let path = args.value_of("path").unwrap_or(".");
let path = args.value_of("path").map(|p| Path::new(p).join("search_index"))
.unwrap_or_else(|| Path::new(&CONFIG.search_index).to_path_buf());
let force = args.is_present("force");
let path = Path::new(path).join("search_index");
let can_do = match read_dir(path.clone()) {
// try to read the directory specified