From 20afcd2b633791c932651e04e340334dabb3ed4e Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Thu, 12 Oct 2023 23:13:50 +0200 Subject: Add commands to print the default configuration (#1241) * Add commands to print the default configuration When updating a software I often want to compare my configuration with the configuration of the new version. To make this possible atuin can now print the default configuration. This also updates the example files with the actual values used as default in the settings.rs files. * Changed command name to 'default-config' * Fixed merge --- atuin-client/src/settings.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'atuin-client/src') diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index e49ab0cb..15aa9e06 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -24,6 +24,7 @@ pub const LAST_SYNC_FILENAME: &str = "last_sync_time"; pub const LAST_VERSION_CHECK_FILENAME: &str = "last_version_check_time"; pub const LATEST_VERSION_FILENAME: &str = "latest_version"; pub const HOST_ID_FILENAME: &str = "host_id"; +static EXAMPLE_CONFIG: &str = include_str!("../config.toml"); #[derive(Clone, Debug, Deserialize, Copy, ValueEnum, PartialEq)] pub enum SearchMode { @@ -410,9 +411,8 @@ impl Settings { FileFormat::Toml, )) } else { - let example_config = include_bytes!("../config.toml"); let mut file = File::create(config_file).wrap_err("could not create config file")?; - file.write_all(example_config) + file.write_all(EXAMPLE_CONFIG.as_bytes()) .wrap_err("could not write default config file")?; config_builder @@ -446,6 +446,10 @@ impl Settings { Ok(settings) } + + pub fn example_config() -> &'static str { + EXAMPLE_CONFIG + } } impl Default for Settings { -- cgit v1.3.1