aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_client/settings.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-12 17:16:19 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-12 17:16:19 +0200
commit2ca7dd57b12861e8c9bbc9238cda612e0ff22ff3 (patch)
tree302a644f6a50d60cc8304c4498fe6bbb72ddaaa9 /crates/turtle/src/atuin_client/settings.rs
parentfeat(server): Really make users stateless (with tests) (diff)
downloadatuin-2ca7dd57b12861e8c9bbc9238cda612e0ff22ff3.zip
chore(treewide): Cleanup themes
Diffstat (limited to 'crates/turtle/src/atuin_client/settings.rs')
-rw-r--r--crates/turtle/src/atuin_client/settings.rs91
1 files changed, 3 insertions, 88 deletions
diff --git a/crates/turtle/src/atuin_client/settings.rs b/crates/turtle/src/atuin_client/settings.rs
index d84e2eb0..c966ba67 100644
--- a/crates/turtle/src/atuin_client/settings.rs
+++ b/crates/turtle/src/atuin_client/settings.rs
@@ -14,7 +14,6 @@ use config::{
};
use eyre::{Context, Error, Result, bail, eyre};
use fs_err::{File, create_dir_all};
-use humantime::parse_duration;
use regex::RegexSet;
use serde::{Deserialize, Serialize};
use serde_with::DeserializeFromStr;
@@ -222,7 +221,6 @@ pub(crate) enum KeymapMode {
Auto,
}
-
// We want to translate the config to crossterm::cursor::SetCursorStyle, but
// the original type does not implement trait serde::Deserialize unfortunately.
// It seems impossible to implement Deserialize for external types when it is
@@ -252,7 +250,6 @@ pub(crate) enum CursorStyle {
SteadyBar,
}
-
#[derive(Clone, Debug, Deserialize, Serialize)]
pub(crate) struct Stats {
#[serde(default = "Stats::common_prefix_default")]
@@ -336,17 +333,6 @@ impl Keys {
prefix: "a".to_string(),
}
}
-
- /// Returns true if any value differs from the standard defaults.
- pub(crate) fn has_non_default_values(&self) -> bool {
- let d = Self::standard_defaults();
- self.scroll_exits != d.scroll_exits
- || self.exit_past_line_start != d.exit_past_line_start
- || self.accept_past_line_end != d.accept_past_line_end
- || self.accept_past_line_start != d.accept_past_line_start
- || self.accept_with_backspace != d.accept_with_backspace
- || self.prefix != d.prefix
- }
}
/// A single rule within a conditional keybinding config.
@@ -403,24 +389,7 @@ pub(crate) struct Preview {
}
#[derive(Clone, Debug, Deserialize, Serialize)]
-pub(crate) struct Theme {
- /// Name of desired theme ("default" for base)
- pub(crate) name: String,
-
- /// Whether any available additional theme debug should be shown
- pub(crate) debug: Option<bool>,
-
- /// How many levels of parenthood will be traversed if needed
- pub(crate) max_depth: Option<u8>,
-}
-
-#[derive(Clone, Debug, Deserialize, Serialize)]
pub(crate) struct Daemon {
- /// Use the daemon to sync
- /// If enabled, history hooks are routed through the daemon.
- #[serde(alias = "enable")]
- pub(crate) enabled: bool,
-
/// Automatically start and manage a local daemon when needed.
pub(crate) autostart: bool,
@@ -534,24 +503,13 @@ impl Default for Preview {
}
}
-impl Default for Theme {
- fn default() -> Self {
- Self {
- name: "".to_string(),
- debug: None::<bool>,
- max_depth: Some(10),
- }
- }
-}
-
impl Default for Daemon {
fn default() -> Self {
Self {
- enabled: false,
autostart: false,
sync_frequency: 300,
- socket_path: "".to_string(),
- pidfile_path: "".to_string(),
+ socket_path: String::new(),
+ pidfile_path: String::new(),
systemd_socket: false,
tcp_port: 8889,
}
@@ -562,7 +520,7 @@ impl Default for Logs {
fn default() -> Self {
Self {
enabled: true,
- dir: "".to_string(),
+ dir: String::new(),
level: LogLevel::default(),
retention: Self::default_retention(),
search: LogConfig {
@@ -621,18 +579,6 @@ impl Logs {
pub(crate) fn daemon_retention(&self) -> u64 {
self.daemon.retention.unwrap_or(self.retention)
}
-
- /// Returns the full path for the search log file.
- pub(crate) fn search_path(&self) -> PathBuf {
- let path = PathBuf::from(&self.search.file);
- PathBuf::from(&self.dir).join(path)
- }
-
- /// Returns the full path for the daemon log file.
- pub(crate) fn daemon_path(&self) -> PathBuf {
- let path = PathBuf::from(&self.daemon.file);
- PathBuf::from(&self.dir).join(path)
- }
}
impl Default for Search {
@@ -902,24 +848,6 @@ impl Sync {
.map(decode_key)
.transpose()
}
-
- pub(crate) async fn should_sync(&self) -> Result<bool> {
- if !self.auto || !self.have_sync_user()? {
- return Ok(false);
- }
-
- if self.frequency == "0" || self.frequency.is_empty() {
- return Ok(true);
- }
-
- match parse_duration(self.frequency.as_str()) {
- Ok(d) => {
- let d = time::Duration::try_from(d)?;
- Ok(OffsetDateTime::now_utc() - Settings::last_sync().await? >= d)
- }
- Err(e) => Err(eyre!("failed to check sync: {}", e)),
- }
- }
}
#[derive(Clone, Debug, Deserialize, Serialize)]
@@ -998,9 +926,6 @@ pub(crate) struct Settings {
pub(crate) search: Search,
#[serde(default)]
- pub(crate) theme: Theme,
-
- #[serde(default)]
pub(crate) ui: Ui,
#[serde(default)]
@@ -1126,7 +1051,6 @@ impl Settings {
.set_default("command_chaining", false)?
.set_default("store_failed", true)?
.set_default("daemon.sync_frequency", 300)?
- .set_default("daemon.enabled", false)?
.set_default("daemon.autostart", false)?
.set_default("daemon.socket_path", socket_path.to_str())?
.set_default("daemon.pidfile_path", pidfile_path.to_str())?
@@ -1553,15 +1477,6 @@ mod tests {
}
#[test]
- fn effective_data_dir_returns_default_when_not_set() {
- let effective = super::Settings::effective_data_dir();
- let default = crate::atuin_common::utils::data_dir();
-
- assert!(effective.to_str().is_some());
- assert!(effective.ends_with("atuin") || effective == default);
- }
-
- #[test]
fn keymap_config_deserializes_simple_binding() {
let json = r#"{"emacs": {"ctrl-c": "exit"}}"#;
let config: super::KeymapConfig = serde_json::from_str(json).unwrap();