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 | |
parent | 14bef9c4a4047e57851c1dad76ae85c121171d49 (diff) |
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')
-rw-r--r-- | atuin-server/server.toml | 13 | ||||
-rw-r--r-- | atuin-server/src/lib.rs | 1 | ||||
-rw-r--r-- | atuin-server/src/settings.rs | 9 |
3 files changed, 21 insertions, 2 deletions
diff --git a/atuin-server/server.toml b/atuin-server/server.toml index 808f15f16..3aed7f9d8 100644 --- a/atuin-server/server.toml +++ b/atuin-server/server.toml @@ -9,3 +9,16 @@ ## URI for postgres (using development creds here) # db_uri="postgres://username:password@localhost/atuin" + +## Maximum size for one history entry +# max_history_length = 8192 + +## Maximum size for one record entry +## 1024 * 1024 * 1024 +# max_record_size = 1073741824 + +## Webhook to be called when user registers on the servers +# register_webhook_username = "" + +## Default page size for requests +# page_size = 1100 diff --git a/atuin-server/src/lib.rs b/atuin-server/src/lib.rs index 810b7db92..007ad5c92 100644 --- a/atuin-server/src/lib.rs +++ b/atuin-server/src/lib.rs @@ -14,6 +14,7 @@ mod router; mod settings; mod utils; +pub use settings::example_config; pub use settings::Settings; use tokio::signal; diff --git a/atuin-server/src/settings.rs b/atuin-server/src/settings.rs index 7e447e9ef..744f4ec23 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 +} |