diff options
| author | Tobias Genannt <tobias.genannt@gmail.com> | 2023-10-12 23:13:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-12 22:13:50 +0100 |
| commit | 20afcd2b633791c932651e04e340334dabb3ed4e (patch) | |
| tree | 9e9e6a4d0dcd117bf94c943863578553e54d1223 /atuin-server/src/settings.rs | |
| parent | Update key-binding.md (#1291) (diff) | |
| download | atuin-20afcd2b633791c932651e04e340334dabb3ed4e.zip | |
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
Diffstat (limited to 'atuin-server/src/settings.rs')
| -rw-r--r-- | atuin-server/src/settings.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/atuin-server/src/settings.rs b/atuin-server/src/settings.rs index 7e447e9e..744f4ec2 100644 --- a/atuin-server/src/settings.rs +++ b/atuin-server/src/settings.rs @@ -5,6 +5,8 @@ use eyre::{eyre, Result}; use fs_err::{create_dir_all, File}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; +static EXAMPLE_CONFIG: &str = include_str!("../server.toml"); + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Settings<DbSettings> { pub host: String, @@ -56,10 +58,9 @@ impl<DbSettings: DeserializeOwned> Settings<DbSettings> { FileFormat::Toml, )) } else { - let example_config = include_bytes!("../server.toml"); create_dir_all(config_file.parent().unwrap())?; let mut file = File::create(config_file)?; - file.write_all(example_config)?; + file.write_all(EXAMPLE_CONFIG.as_bytes())?; config_builder }; @@ -71,3 +72,7 @@ impl<DbSettings: DeserializeOwned> Settings<DbSettings> { .map_err(|e| eyre!("failed to deserialize: {}", e)) } } + +pub fn example_config() -> &'static str { + EXAMPLE_CONFIG +} |
