summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-02-27 10:37:36 +0100
committerCanop <cano.petrole@gmail.com>2021-02-27 10:37:36 +0100
commitb4d2647708b3bc2fdc064b0660f715879db18818 (patch)
tree37471d9cb5bc57d06a0238d5e918ed36e99726ca
parent4bf1ad20ef1feb8025921e1d77ee8dcdb4ca15cd (diff)
move default conf from source code to a resource file
It makes it easier to read it or modify it, especially for new contributors. This also simplifies the release wrapping.
-rw-r--r--build.rs13
-rw-r--r--resources/default-conf.hjson (renamed from src/conf/default_conf.rs)8
-rw-r--r--src/conf/mod.rs9
3 files changed, 7 insertions, 23 deletions
diff --git a/build.rs b/build.rs
index e7a3914..5d88c3c 100644
--- a/build.rs
+++ b/build.rs
@@ -5,14 +5,11 @@ use {
clap::Shell,
std::{
env,
- fs,
str::FromStr,
- path::Path,
},
};
include!("src/cli/clap_args.rs");
-include!("src/conf/default_conf.rs");
/// write the shell completion scripts which will be added to
/// the release archive
@@ -29,16 +26,6 @@ fn build_completion_scripts() {
println!("completion scripts generated in {:?}", out_dir);
}
-/// write the default configuration file, which will be added to
-/// the release archive
-fn build_default_conf() {
- let out_dir = env::var_os("OUT_DIR").expect("out dir not set");
- let file_path = Path::new(&out_dir).join("default-conf.hjson");
- fs::write(&file_path, DEFAULT_CONF_FILE).expect("it to work :'(");
- println!("default conf written in {:?}", file_path);
-}
-
fn main() {
build_completion_scripts();
- build_default_conf();
}
diff --git a/src/conf/default_conf.rs b/resources/default-conf.hjson
index b8a21e4..f4eb587 100644
--- a/src/conf/default_conf.rs
+++ b/resources/default-conf.hjson
@@ -1,10 +1,3 @@
-
-/// the content a the conf.hjson file broot creates
-/// when there's none. It features some default
-/// configuration and many completable
-/// or uncommentable sections to help the user
-/// define their own configuration.
-pub const DEFAULT_CONF_FILE: &str = r#"
###############################################################
# This configuration file lets you
# - define new commands
@@ -335,4 +328,3 @@ pub const DEFAULT_CONF_FILE: &str = r#"
# open
# max_panels_count: 2
}
-"#;
diff --git a/src/conf/mod.rs b/src/conf/mod.rs
index 89b71f4..394c9b0 100644
--- a/src/conf/mod.rs
+++ b/src/conf/mod.rs
@@ -4,17 +4,22 @@ use {
};
mod conf;
-mod default_conf;
mod format;
mod verb_conf;
pub use {
conf::Conf,
- default_conf::*,
format::*,
verb_conf::VerbConf,
};
+
+/// the content of the conf.hjson file broot creates when there's none.
+///
+/// It features some default configuration and many sections the user
+/// can uncomment then edit.
+pub const DEFAULT_CONF_FILE: &str = include_str!("../../resources/default-conf.hjson");
+
/// return the instance of ProjectDirs holding broot's specific paths
pub fn app_dirs() -> directories::ProjectDirs {
directories::ProjectDirs::from("org", "dystroy", "broot")