diff options
Diffstat (limited to 'crates/turtle/src/command')
53 files changed, 295 insertions, 295 deletions
diff --git a/crates/turtle/src/command/client.rs b/crates/turtle/src/command/client.rs index 20d85303..15df60f8 100644 --- a/crates/turtle/src/command/client.rs +++ b/crates/turtle/src/command/client.rs @@ -65,7 +65,7 @@ mod wrapped; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Setup Atuin features #[command()] Setup, @@ -129,7 +129,7 @@ pub enum Cmd { } impl Cmd { - pub fn run(self) -> Result<()> { + pub(crate) fn run(self) -> Result<()> { // Daemonize before creating the async runtime – fork() inside a live // tokio runtime corrupts its internal state. #[cfg(all(unix, feature = "daemon"))] diff --git a/crates/turtle/src/command/client/account.rs b/crates/turtle/src/command/client/account.rs index 898f1ac4..f2ceb10b 100644 --- a/crates/turtle/src/command/client/account.rs +++ b/crates/turtle/src/command/client/account.rs @@ -4,20 +4,20 @@ use eyre::Result; use crate::atuin_client::record::sqlite_store::SqliteStore; use crate::atuin_client::settings::Settings; -pub mod change_password; -pub mod delete; -pub mod login; -pub mod logout; -pub mod register; +pub(crate) mod change_password; +pub(crate) mod delete; +pub(crate) mod login; +pub(crate) mod logout; +pub(crate) mod register; #[derive(Args, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { #[command(subcommand)] command: Commands, } #[derive(Subcommand, Debug)] -pub enum Commands { +pub(crate) enum Commands { /// Login to the configured server Login(login::Cmd), @@ -35,7 +35,7 @@ pub enum Commands { } impl Cmd { - pub async fn run(self, settings: Settings, store: SqliteStore) -> Result<()> { + pub(crate) async fn run(self, settings: Settings, store: SqliteStore) -> Result<()> { match self.command { Commands::Login(l) => l.run(&settings, &store).await, Commands::Register(r) => r.run(&settings).await, diff --git a/crates/turtle/src/command/client/account/change_password.rs b/crates/turtle/src/command/client/account/change_password.rs index 6112b0df..f7f7eb69 100644 --- a/crates/turtle/src/command/client/account/change_password.rs +++ b/crates/turtle/src/command/client/account/change_password.rs @@ -8,20 +8,20 @@ use crate::atuin_client::{ use rpassword::prompt_password; #[derive(Parser, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { #[clap(long, short)] - pub current_password: Option<String>, + pub(crate) current_password: Option<String>, #[clap(long, short)] - pub new_password: Option<String>, + pub(crate) new_password: Option<String>, /// The two-factor authentication code for your account, if any #[clap(long, short)] - pub totp_code: Option<String>, + pub(crate) totp_code: Option<String>, } impl Cmd { - pub async fn run(&self, settings: &Settings) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings) -> Result<()> { if !settings.logged_in().await? { bail!("You are not logged in"); } diff --git a/crates/turtle/src/command/client/account/delete.rs b/crates/turtle/src/command/client/account/delete.rs index bcb40bc3..1c96cb4a 100644 --- a/crates/turtle/src/command/client/account/delete.rs +++ b/crates/turtle/src/command/client/account/delete.rs @@ -8,17 +8,17 @@ use eyre::{Result, bail}; use super::login::{or_user_input, read_user_password}; #[derive(Parser, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { #[clap(long, short)] - pub password: Option<String>, + pub(crate) password: Option<String>, /// The two-factor authentication code for your account, if any #[clap(long, short)] - pub totp_code: Option<String>, + pub(crate) totp_code: Option<String>, } impl Cmd { - pub async fn run(&self, settings: &Settings) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings) -> Result<()> { if !settings.logged_in().await? { bail!("You are not logged in"); } diff --git a/crates/turtle/src/command/client/account/login.rs b/crates/turtle/src/command/client/account/login.rs index 0c5b66f5..1ec0293a 100644 --- a/crates/turtle/src/command/client/account/login.rs +++ b/crates/turtle/src/command/client/account/login.rs @@ -15,23 +15,23 @@ use crate::atuin_client::{ use rpassword::prompt_password; #[derive(Parser, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { #[clap(long, short)] - pub username: Option<String>, + pub(crate) username: Option<String>, #[clap(long, short)] - pub password: Option<String>, + pub(crate) password: Option<String>, /// The encryption key for your account #[clap(long, short)] - pub key: Option<String>, + pub(crate) key: Option<String>, /// The two-factor authentication code for your account, if any #[clap(long, short)] - pub totp_code: Option<String>, + pub(crate) totp_code: Option<String>, #[clap(long, hide = true)] - pub from_registration: bool, + pub(crate) from_registration: bool, } fn get_input() -> Result<String> { @@ -41,7 +41,7 @@ fn get_input() -> Result<String> { } impl Cmd { - pub async fn run(&self, settings: &Settings, store: &SqliteStore) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings, store: &SqliteStore) -> Result<()> { match settings.resolve_sync_auth().await { SyncAuth::Legacy { .. } => { println!("You are logged in to your sync server."); diff --git a/crates/turtle/src/command/client/account/logout.rs b/crates/turtle/src/command/client/account/logout.rs index 6150a52b..5708e34c 100644 --- a/crates/turtle/src/command/client/account/logout.rs +++ b/crates/turtle/src/command/client/account/logout.rs @@ -1,5 +1,5 @@ use eyre::Result; -pub async fn run() -> Result<()> { +pub(crate) async fn run() -> Result<()> { crate::atuin_client::logout::logout().await } diff --git a/crates/turtle/src/command/client/account/register.rs b/crates/turtle/src/command/client/account/register.rs index 548c2739..64fb9f8d 100644 --- a/crates/turtle/src/command/client/account/register.rs +++ b/crates/turtle/src/command/client/account/register.rs @@ -5,19 +5,19 @@ use super::login::or_user_input; use crate::atuin_client::settings::{Settings, SyncAuth}; #[derive(Parser, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { #[clap(long, short)] - pub username: Option<String>, + pub(crate) username: Option<String>, #[clap(long, short)] - pub password: Option<String>, + pub(crate) password: Option<String>, #[clap(long, short)] - pub email: Option<String>, + pub(crate) email: Option<String>, } impl Cmd { - pub async fn run(&self, settings: &Settings) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings) -> Result<()> { match settings.resolve_sync_auth().await { SyncAuth::Legacy { .. } => { println!("You are already logged in."); diff --git a/crates/turtle/src/command/client/config.rs b/crates/turtle/src/command/client/config.rs index 1597a8d6..73d1c35e 100644 --- a/crates/turtle/src/command/client/config.rs +++ b/crates/turtle/src/command/client/config.rs @@ -5,7 +5,7 @@ use toml_edit::{Document, DocumentMut, Item, Table, TableLike, Value}; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Get a configuration value from your config.toml file /// or after defaults and overrides are applied #[command()] @@ -24,7 +24,7 @@ pub enum Cmd { } impl Cmd { - pub async fn run(self, settings: &Settings) -> Result<()> { + pub(crate) async fn run(self, settings: &Settings) -> Result<()> { match self { Self::Get(get) => get.run(settings).await, Self::Set(set) => set.run(settings).await, @@ -36,21 +36,21 @@ impl Cmd { /// Get a configuration value from your config.toml file, /// or optionally the effective value after defaults and overrides are applied. #[derive(Args, Debug)] -pub struct GetCmd { +pub(crate) struct GetCmd { /// The configuration key to get - pub key: String, + pub(crate) key: String, /// Print the value after defaults and overrides are applied #[arg(long, short)] - pub resolved: bool, + pub(crate) resolved: bool, /// Print both the config file value and the resolved value #[arg(long, short)] - pub verbose: bool, + pub(crate) verbose: bool, } impl GetCmd { - pub async fn run(&self, _settings: &Settings) -> Result<()> { + pub(crate) async fn run(&self, _settings: &Settings) -> Result<()> { let key = self.key.trim(); if key.is_empty() || key.contains(char::is_whitespace) { eyre::bail!("Config key must be non-empty and must not contain whitespace"); @@ -116,20 +116,20 @@ impl GetCmd { } #[derive(Args, Debug)] -pub struct SetCmd { +pub(crate) struct SetCmd { /// The configuration key to set - pub key: String, + pub(crate) key: String, /// The value to set - pub value: String, + pub(crate) value: String, /// Store value as an explicit type #[arg(long = "type", short, value_enum, default_value_t = ValueType::Auto, value_name = "TYPE")] - pub the_type: ValueType, + pub(crate) the_type: ValueType, } #[derive(ValueEnum, Debug, Clone, PartialEq, Eq)] -pub enum ValueType { +pub(crate) enum ValueType { /// Automatically determine the type of the value Auto, /// Store value as a string @@ -143,7 +143,7 @@ pub enum ValueType { } impl SetCmd { - pub async fn run(self, _settings: &Settings) -> Result<()> { + pub(crate) async fn run(self, _settings: &Settings) -> Result<()> { let key = self.key.trim(); if key.is_empty() || key.contains(char::is_whitespace) { eyre::bail!("Config key must be non-empty and must not contain whitespace"); @@ -213,13 +213,13 @@ impl SetCmd { } #[derive(Args, Debug)] -pub struct PrintCmd { +pub(crate) struct PrintCmd { /// Print the value of a specific key and all its children - pub key: Option<String>, + pub(crate) key: Option<String>, } impl PrintCmd { - pub async fn run(&self, _settings: &Settings) -> Result<()> { + pub(crate) async fn run(&self, _settings: &Settings) -> Result<()> { let config_file = Settings::get_config_path()?; let config_str = tokio::fs::read_to_string(&config_file).await?; let doc = config_str.parse::<Document<_>>()?; diff --git a/crates/turtle/src/command/client/daemon.rs b/crates/turtle/src/command/client/daemon.rs index 2ee9b759..2fb090aa 100644 --- a/crates/turtle/src/command/client/daemon.rs +++ b/crates/turtle/src/command/client/daemon.rs @@ -21,7 +21,7 @@ use fs4::fs_std::FileExt; use tokio::time::sleep; #[derive(clap::Args, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { /// Internal flag for daemonization #[arg(long, hide = true)] daemonize: bool, @@ -36,7 +36,7 @@ pub struct Cmd { #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub enum SubCmd { +pub(crate) enum SubCmd { /// Start the daemon server Start { #[arg(long, hide = true)] @@ -65,7 +65,7 @@ impl Cmd { /// Returns `true` when the process should daemonize before creating the /// async runtime or opening any database connections. #[cfg(unix)] - pub fn should_daemonize(&self) -> bool { + pub(crate) fn should_daemonize(&self) -> bool { match &self.subcmd { Some(SubCmd::Start { daemonize, .. }) => *daemonize, None => self.daemonize, @@ -74,7 +74,7 @@ impl Cmd { } /// Returns `true` when logs should also be written to the console. - pub fn show_logs(&self) -> bool { + pub(crate) fn show_logs(&self) -> bool { match &self.subcmd { Some(SubCmd::Start { show_logs, .. }) => *show_logs, None => self.show_logs, @@ -82,7 +82,7 @@ impl Cmd { } } - pub async fn run( + pub(crate) async fn run( self, settings: Settings, store: SqliteStore, @@ -350,7 +350,7 @@ fn ensure_autostart_supported(settings: &Settings) -> Result<()> { /// process and wait for it to become ready. /// /// Returns an error if the daemon could not be started. -pub async fn ensure_daemon_running(settings: &Settings) -> Result<()> { +pub(crate) async fn ensure_daemon_running(settings: &Settings) -> Result<()> { ensure_autostart_supported(settings)?; let timeout = startup_timeout(settings); @@ -404,7 +404,7 @@ fn ensure_reply_compatible(settings: &Settings, version: &str, protocol: u32) -> bail!("{message}. Enable `daemon.autostart = true` or restart the daemon manually"); } -pub async fn start_history(settings: &Settings, history: History) -> Result<String> { +pub(crate) async fn start_history(settings: &Settings, history: History) -> Result<String> { match async { connect_client(settings) .await? @@ -438,7 +438,7 @@ pub async fn start_history(settings: &Settings, history: History) -> Result<Stri Ok(resp.id) } -pub async fn end_history(settings: &Settings, id: String, duration: u64, exit: i64) -> Result<()> { +pub(crate) async fn end_history(settings: &Settings, id: String, duration: u64, exit: i64) -> Result<()> { match async { connect_client(settings) .await? @@ -482,7 +482,7 @@ pub async fn end_history(settings: &Settings, id: String, duration: u64, exit: i /// If the daemon is not reachable and `daemon.autostart` is enabled, this /// will start the daemon and retry the event. If the daemon cannot be /// started or the retry fails, a warning is printed to stderr. -pub async fn emit_event(settings: &Settings, event: DaemonEvent) { +pub(crate) async fn emit_event(settings: &Settings, event: DaemonEvent) { // Try to connect and send match ControlClient::from_settings(settings).await { Ok(mut client) => { @@ -516,7 +516,7 @@ pub async fn emit_event(settings: &Settings, event: DaemonEvent) { } } -pub async fn tail_client(settings: &Settings) -> Result<HistoryClient> { +pub(crate) async fn tail_client(settings: &Settings) -> Result<HistoryClient> { match probe(settings).await { Probe::Ready(client) => return Ok(client), Probe::NeedsRestart(reason) if !settings.daemon.autostart => { @@ -619,7 +619,7 @@ async fn restart_cmd(settings: &Settings) -> Result<()> { /// runtime or opening database connections, since `fork()` inside an async /// runtime corrupts its internal state. #[cfg(unix)] -pub fn daemonize_current_process() -> Result<()> { +pub(crate) fn daemonize_current_process() -> Result<()> { let cwd = std::env::current_dir().wrap_err("could not determine current directory for daemon")?; diff --git a/crates/turtle/src/command/client/default_config.rs b/crates/turtle/src/command/client/default_config.rs index e8cc15f9..4b03c909 100644 --- a/crates/turtle/src/command/client/default_config.rs +++ b/crates/turtle/src/command/client/default_config.rs @@ -1,4 +1,4 @@ -pub fn run() { +pub(crate) fn run() { // TODO(@bpeetz): Re-add the default settings option back (Settings::example_config()) <2026-06-11> println!("TODO"); } diff --git a/crates/turtle/src/command/client/doctor.rs b/crates/turtle/src/command/client/doctor.rs index 09fa6e77..1ed90c47 100644 --- a/crates/turtle/src/command/client/doctor.rs +++ b/crates/turtle/src/command/client/doctor.rs @@ -13,17 +13,17 @@ use sysinfo::{Disks, System, get_current_pid}; #[derive(Debug, Serialize)] struct ShellInfo { - pub name: String, + pub(crate) name: String, // best-effort, not supported on all OSes - pub default: String, + pub(crate) default: String, // Detect some shell plugins that the user has installed. // I'm just going to start with preexec/blesh - pub plugins: Vec<String>, + pub(crate) plugins: Vec<String>, // The preexec framework used in the current session, if Atuin is loaded. - pub preexec: Option<String>, + pub(crate) preexec: Option<String>, } impl ShellInfo { @@ -86,7 +86,7 @@ impl ShellInfo { .map(|_| "blesh".to_string()) } - pub fn plugins(shell: &str, shell_process: &sysinfo::Process) -> Vec<String> { + pub(crate) fn plugins(shell: &str, shell_process: &sysinfo::Process) -> Vec<String> { // consider a different detection approach if there are plugins // that don't set shell vars @@ -167,7 +167,7 @@ impl ShellInfo { .collect() } - pub fn new() -> Self { + pub(crate) fn new() -> Self { // TODO: rework to use crate::atuin_common::Shell let sys = System::new_all(); @@ -199,22 +199,22 @@ impl ShellInfo { #[derive(Debug, Serialize)] struct DiskInfo { - pub name: String, - pub filesystem: String, + pub(crate) name: String, + pub(crate) filesystem: String, } #[derive(Debug, Serialize)] struct SystemInfo { - pub os: String, + pub(crate) os: String, - pub arch: String, + pub(crate) arch: String, - pub version: String, - pub disks: Vec<DiskInfo>, + pub(crate) version: String, + pub(crate) disks: Vec<DiskInfo>, } impl SystemInfo { - pub fn new() -> Self { + pub(crate) fn new() -> Self { let disks = Disks::new_with_refreshed_list(); let disks = disks .list() @@ -236,14 +236,14 @@ impl SystemInfo { #[derive(Debug, Serialize)] struct SyncInfo { - pub auth_state: String, - pub auto_sync: bool, + pub(crate) auth_state: String, + pub(crate) auto_sync: bool, - pub last_sync: String, + pub(crate) last_sync: String, } impl SyncInfo { - pub async fn new(settings: &Settings) -> Self { + pub(crate) async fn new(settings: &Settings) -> Self { // Build auth state description from raw token state without calling // resolve_sync_auth(), which has side effects (token migration cleanup) // that a diagnostic command should not trigger. @@ -277,7 +277,7 @@ struct SettingPaths { } impl SettingPaths { - pub fn new(settings: &Settings) -> Self { + pub(crate) fn new(settings: &Settings) -> Self { Self { db: settings.db_path.clone(), record_store: settings.record_store_path.clone(), @@ -285,7 +285,7 @@ impl SettingPaths { } } - pub fn verify(&self) { + pub(crate) fn verify(&self) { let paths = vec![ ("ATUIN_DB_PATH", &self.db), ("ATUIN_RECORD_STORE", &self.record_store), @@ -304,21 +304,21 @@ impl SettingPaths { #[derive(Debug, Serialize)] struct AtuinInfo { - pub version: String, - pub commit: String, + pub(crate) version: String, + pub(crate) commit: String, /// Whether the main Atuin sync server is in use /// I'm just calling it Atuin Cloud for lack of a better name atm - pub sync: Option<SyncInfo>, + pub(crate) sync: Option<SyncInfo>, - pub sqlite_version: String, + pub(crate) sqlite_version: String, #[serde(skip)] // probably unnecessary to expose this - pub setting_paths: SettingPaths, + pub(crate) setting_paths: SettingPaths, } impl AtuinInfo { - pub async fn new(settings: &Settings) -> Self { + pub(crate) async fn new(settings: &Settings) -> Self { let logged_in = settings.logged_in().await.unwrap_or(false); let sync = if logged_in { @@ -347,13 +347,13 @@ impl AtuinInfo { #[derive(Debug, Serialize)] struct DoctorDump { - pub atuin: AtuinInfo, - pub shell: ShellInfo, - pub system: SystemInfo, + pub(crate) atuin: AtuinInfo, + pub(crate) shell: ShellInfo, + pub(crate) system: SystemInfo, } impl DoctorDump { - pub async fn new(settings: &Settings) -> Self { + pub(crate) async fn new(settings: &Settings) -> Self { Self { atuin: AtuinInfo::new(settings).await, shell: ShellInfo::new(), @@ -396,7 +396,7 @@ fn checks(info: &DoctorDump) { } } -pub async fn run(settings: &Settings) -> Result<()> { +pub(crate) async fn run(settings: &Settings) -> Result<()> { println!("{}", "Atuin Doctor".bold()); println!("Checking for diagnostics"); let dump = DoctorDump::new(settings).await; diff --git a/crates/turtle/src/command/client/history.rs b/crates/turtle/src/command/client/history.rs index 0c61392c..e533759b 100644 --- a/crates/turtle/src/command/client/history.rs +++ b/crates/turtle/src/command/client/history.rs @@ -43,7 +43,7 @@ use super::search::format_duration_into; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Begins a new command in the history Start { /// Collects the command from the `ATUIN_COMMAND_LINE` environment variable, @@ -163,14 +163,14 @@ pub enum Cmd { } #[derive(Clone, Copy, Debug)] -pub enum ListMode { +pub(crate) enum ListMode { Human, CmdOnly, Regular, } impl ListMode { - pub const fn from_flags(human: bool, cmd_only: bool) -> Self { + pub(crate) const fn from_flags(human: bool, cmd_only: bool) -> Self { if human { ListMode::Human } else if cmd_only { @@ -182,7 +182,7 @@ impl ListMode { } #[expect(clippy::cast_sign_loss)] -pub fn print_list( +pub(crate) fn print_list( h: &[History], list_mode: ListMode, format: Option<&str>, @@ -1078,7 +1078,7 @@ impl Cmd { } #[expect(clippy::too_many_lines)] - pub async fn run(self, settings: &Settings) -> Result<()> { + pub(crate) async fn run(self, settings: &Settings) -> Result<()> { match self { Self::Start { cmd_env, diff --git a/crates/turtle/src/command/client/import.rs b/crates/turtle/src/command/client/import.rs index 363e6405..3ec524d2 100644 --- a/crates/turtle/src/command/client/import.rs +++ b/crates/turtle/src/command/client/import.rs @@ -17,7 +17,7 @@ use crate::atuin_client::{ #[derive(Parser, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Import history for the current shell Auto, @@ -49,7 +49,7 @@ const BATCH_SIZE: usize = 100; impl Cmd { #[expect(clippy::cognitive_complexity)] - pub async fn run<DB: Database>(&self, db: &DB) -> Result<()> { + pub(crate) async fn run<DB: Database>(&self, db: &DB) -> Result<()> { println!(" Atuin "); println!("======================"); println!(" \u{1f30d} "); @@ -135,7 +135,7 @@ impl Cmd { } } -pub struct HistoryImporter<'db, DB: Database> { +pub(crate) struct HistoryImporter<'db, DB: Database> { pb: ProgressBar, buf: Vec<History>, db: &'db DB, diff --git a/crates/turtle/src/command/client/info.rs b/crates/turtle/src/command/client/info.rs index ee24c419..fc944987 100644 --- a/crates/turtle/src/command/client/info.rs +++ b/crates/turtle/src/command/client/info.rs @@ -2,7 +2,7 @@ use crate::atuin_client::settings::Settings; use crate::{SHA, VERSION};
-pub fn run(settings: &Settings) {
+pub(crate) fn run(settings: &Settings) {
let config = crate::atuin_common::utils::config_dir();
let mut config_file = config.clone();
config_file.push("config.toml");
diff --git a/crates/turtle/src/command/client/init.rs b/crates/turtle/src/command/client/init.rs index bf9747bb..776100cf 100644 --- a/crates/turtle/src/command/client/init.rs +++ b/crates/turtle/src/command/client/init.rs @@ -8,7 +8,7 @@ mod xonsh; mod zsh; #[derive(Parser, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { shell: Shell, /// Disable the binding of CTRL-R to atuin @@ -27,7 +27,7 @@ pub struct Cmd { #[derive(Clone, Copy, ValueEnum, Debug)] #[value(rename_all = "lower")] #[expect(clippy::enum_variant_names, clippy::doc_markdown)] -pub enum Shell { +pub(crate) enum Shell { /// Zsh setup Zsh, /// Bash setup @@ -115,7 +115,7 @@ $env.config = ( } } - pub fn run(self, settings: &Settings) { + pub(crate) fn run(self, settings: &Settings) { if !settings.paths_ok() { eprintln!( "Atuin settings paths are broken. Disabling atuin shell hooks. Run `atuin doctor` to diagnose." diff --git a/crates/turtle/src/command/client/init/bash.rs b/crates/turtle/src/command/client/init/bash.rs index fd17e37e..a5f6eb8d 100644 --- a/crates/turtle/src/command/client/init/bash.rs +++ b/crates/turtle/src/command/client/init/bash.rs @@ -9,7 +9,7 @@ fn print_tmux_config(tmux: &Tmux) { } } -pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, tmux: &Tmux) { +pub(crate) fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, tmux: &Tmux) { let base = include_str!("../../../shell/atuin.bash"); let (bind_ctrl_r, bind_up_arrow) = if std::env::var("ATUIN_NOBIND").is_ok() { diff --git a/crates/turtle/src/command/client/init/fish.rs b/crates/turtle/src/command/client/init/fish.rs index 8a046bfa..27325bcd 100644 --- a/crates/turtle/src/command/client/init/fish.rs +++ b/crates/turtle/src/command/client/init/fish.rs @@ -35,7 +35,7 @@ fn print_bindings( println!("{indent}end"); } -pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, tmux: &Tmux) { +pub(crate) fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, tmux: &Tmux) { let indent = " ".repeat(4); let base = include_str!("../../../shell/atuin.fish"); diff --git a/crates/turtle/src/command/client/init/powershell.rs b/crates/turtle/src/command/client/init/powershell.rs index 10c0c461..8deb9a3b 100644 --- a/crates/turtle/src/command/client/init/powershell.rs +++ b/crates/turtle/src/command/client/init/powershell.rs @@ -1,6 +1,6 @@ use crate::atuin_client::settings::Tmux; -pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, _tmux: &Tmux) { +pub(crate) fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, _tmux: &Tmux) { let base = include_str!("../../../shell/atuin.ps1"); let (bind_ctrl_r, bind_up_arrow) = if std::env::var("ATUIN_NOBIND").is_ok() { diff --git a/crates/turtle/src/command/client/init/xonsh.rs b/crates/turtle/src/command/client/init/xonsh.rs index a17d85d8..ccb71880 100644 --- a/crates/turtle/src/command/client/init/xonsh.rs +++ b/crates/turtle/src/command/client/init/xonsh.rs @@ -1,6 +1,6 @@ use crate::atuin_client::settings::Tmux; -pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, _tmux: &Tmux) { +pub(crate) fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, _tmux: &Tmux) { let base = include_str!("../../../shell/atuin.xsh"); let (bind_ctrl_r, bind_up_arrow) = if std::env::var("ATUIN_NOBIND").is_ok() { diff --git a/crates/turtle/src/command/client/init/zsh.rs b/crates/turtle/src/command/client/init/zsh.rs index 38c3086b..60d0138f 100644 --- a/crates/turtle/src/command/client/init/zsh.rs +++ b/crates/turtle/src/command/client/init/zsh.rs @@ -9,7 +9,7 @@ fn print_tmux_config(tmux: &Tmux) { } } -pub fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, tmux: &Tmux) { +pub(crate) fn init_static(disable_up_arrow: bool, disable_ctrl_r: bool, tmux: &Tmux) { let base = include_str!("../../../shell/atuin.zsh"); print_tmux_config(tmux); diff --git a/crates/turtle/src/command/client/search.rs b/crates/turtle/src/command/client/search.rs index 4a2114d5..72112084 100644 --- a/crates/turtle/src/command/client/search.rs +++ b/crates/turtle/src/command/client/search.rs @@ -23,13 +23,13 @@ mod engines; mod history_list; mod inspector; mod interactive; -pub mod keybindings; +pub(crate) mod keybindings; -pub use duration::format_duration_into; +pub(crate) use duration::format_duration_into; #[expect(clippy::struct_excessive_bools, clippy::struct_field_names)] #[derive(Parser, Debug)] -pub struct Cmd { +pub(crate) struct Cmd { /// Filter search result by directory #[arg(long, short)] cwd: Option<String>, @@ -147,7 +147,7 @@ pub struct Cmd { impl Cmd { /// Returns true if this search command will run in interactive (TUI) mode - pub fn is_interactive(&self) -> bool { + pub(crate) fn is_interactive(&self) -> bool { self.interactive } @@ -155,7 +155,7 @@ impl Cmd { // clippy: now it has too many lines // me: I'll do it later OKAY #[expect(clippy::too_many_lines)] - pub async fn run( + pub(crate) async fn run( self, db: impl Database, settings: &mut Settings, diff --git a/crates/turtle/src/command/client/search/cursor.rs b/crates/turtle/src/command/client/search/cursor.rs index 84f94082..a69f1359 100644 --- a/crates/turtle/src/command/client/search/cursor.rs +++ b/crates/turtle/src/command/client/search/cursor.rs @@ -1,6 +1,6 @@ use crate::atuin_client::settings::WordJumpMode; -pub struct Cursor { +pub(crate) struct Cursor { source: String, index: usize, } @@ -11,7 +11,7 @@ impl From<String> for Cursor { } } -pub struct WordJumper<'a> { +pub(crate) struct WordJumper<'a> { word_chars: &'a str, word_jump_mode: WordJumpMode, } @@ -93,25 +93,25 @@ impl WordJumper<'_> { } impl Cursor { - pub fn as_str(&self) -> &str { + pub(crate) fn as_str(&self) -> &str { self.source.as_str() } - pub fn into_inner(self) -> String { + pub(crate) fn into_inner(self) -> String { self.source } /// Returns the string before the cursor - pub fn substring(&self) -> &str { + pub(crate) fn substring(&self) -> &str { &self.source[..self.index] } /// Returns the currently selected [`char`] - pub fn char(&self) -> Option<char> { + pub(crate) fn char(&self) -> Option<char> { self.source[self.index..].chars().next() } - pub fn right(&mut self) { + pub(crate) fn right(&mut self) { if self.index < self.source.len() { loop { self.index += 1; @@ -122,7 +122,7 @@ impl Cursor { } } - pub fn left(&mut self) -> bool { + pub(crate) fn left(&mut self) -> bool { if self.index > 0 { loop { self.index -= 1; @@ -135,7 +135,7 @@ impl Cursor { } } - pub fn next_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { + pub(crate) fn next_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { let word_jumper = WordJumper { word_chars, word_jump_mode, @@ -143,7 +143,7 @@ impl Cursor { self.index = word_jumper.get_next_word_pos(&self.source, self.index); } - pub fn prev_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { + pub(crate) fn prev_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { let word_jumper = WordJumper { word_chars, word_jump_mode, @@ -156,7 +156,7 @@ impl Cursor { /// If cursor is in the middle of a word, moves to the end of that word. /// If cursor is at the end of a word (or on whitespace), moves to the /// end of the next word. - pub fn word_end(&mut self, word_chars: &str) { + pub(crate) fn word_end(&mut self, word_chars: &str) { let len = self.source.len(); if self.index >= len { return; @@ -213,12 +213,12 @@ impl Cursor { self.index = chars.iter().take(char_idx).map(|c| c.len_utf8()).sum(); } - pub fn insert(&mut self, c: char) { + pub(crate) fn insert(&mut self, c: char) { self.source.insert(self.index, c); self.index += c.len_utf8(); } - pub fn remove(&mut self) -> Option<char> { + pub(crate) fn remove(&mut self) -> Option<char> { if self.index < self.source.len() { Some(self.source.remove(self.index)) } else { @@ -226,7 +226,7 @@ impl Cursor { } } - pub fn remove_next_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { + pub(crate) fn remove_next_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { let word_jumper = WordJumper { word_chars, word_jump_mode, @@ -235,7 +235,7 @@ impl Cursor { self.source.replace_range(self.index..next_index, ""); } - pub fn remove_prev_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { + pub(crate) fn remove_prev_word(&mut self, word_chars: &str, word_jump_mode: WordJumpMode) { let word_jumper = WordJumper { word_chars, word_jump_mode, @@ -245,34 +245,34 @@ impl Cursor { self.index = next_index; } - pub fn back(&mut self) -> Option<char> { + pub(crate) fn back(&mut self) -> Option<char> { if self.left() { self.remove() } else { None } } - pub fn clear(&mut self) { + pub(crate) fn clear(&mut self) { self.source.clear(); self.index = 0; } - pub fn clear_to_start(&mut self) { + pub(crate) fn clear_to_start(&mut self) { self.source.replace_range(..self.index, ""); self.index = 0; } - pub fn clear_to_end(&mut self) { + pub(crate) fn clear_to_end(&mut self) { self.source.replace_range(self.index.., ""); self.index = self.source.len(); } - pub fn end(&mut self) { + pub(crate) fn end(&mut self) { self.index = self.source.len(); } - pub fn start(&mut self) { + pub(crate) fn start(&mut self) { self.index = 0; } - pub fn position(&self) -> usize { + pub(crate) fn position(&self) -> usize { self.index } } diff --git a/crates/turtle/src/command/client/search/duration.rs b/crates/turtle/src/command/client/search/duration.rs index 54856c87..bc8dbed3 100644 --- a/crates/turtle/src/command/client/search/duration.rs +++ b/crates/turtle/src/command/client/search/duration.rs @@ -2,7 +2,7 @@ use core::fmt; use std::{ops::ControlFlow, time::Duration}; #[expect(clippy::module_name_repetitions)] -pub fn format_duration_into(dur: Duration, f: &mut fmt::Formatter<'_>) -> fmt::Result { +pub(crate) fn format_duration_into(dur: Duration, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn item(unit: &'static str, value: u64) -> ControlFlow<(&'static str, u64)> { if value > 0 { ControlFlow::Break((unit, value)) @@ -54,7 +54,7 @@ pub fn format_duration_into(dur: Duration, f: &mut fmt::Formatter<'_>) -> fmt::R } #[expect(clippy::module_name_repetitions)] -pub fn format_duration(f: Duration) -> String { +pub(crate) fn format_duration(f: Duration) -> String { struct F(Duration); impl fmt::Display for F { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/crates/turtle/src/command/client/search/engines.rs b/crates/turtle/src/command/client/search/engines.rs index 0f92b4c7..d6335a38 100644 --- a/crates/turtle/src/command/client/search/engines.rs +++ b/crates/turtle/src/command/client/search/engines.rs @@ -9,12 +9,12 @@ use eyre::Result; use super::cursor::Cursor; #[cfg(feature = "daemon")] -pub mod daemon; -pub mod db; -pub mod skim; +pub(crate) mod daemon; +pub(crate) mod db; +pub(crate) mod skim; #[expect(unused)] // settings is only used if daemon feature is enabled -pub fn engine(search_mode: SearchMode, settings: &Settings) -> Box<dyn SearchEngine> { +pub(crate) fn engine(search_mode: SearchMode, settings: &Settings) -> Box<dyn SearchEngine> { match search_mode { SearchMode::Skim => Box::new(skim::Search::new()) as Box<_>, #[cfg(feature = "daemon")] @@ -28,11 +28,11 @@ pub fn engine(search_mode: SearchMode, settings: &Settings) -> Box<dyn SearchEng } } -pub struct SearchState { - pub input: Cursor, - pub filter_mode: FilterMode, - pub context: Context, - pub custom_context: Option<HistoryId>, +pub(crate) struct SearchState { + pub(crate) input: Cursor, + pub(crate) filter_mode: FilterMode, + pub(crate) context: Context, + pub(crate) custom_context: Option<HistoryId>, } impl SearchState { @@ -63,7 +63,7 @@ impl SearchState { } #[async_trait] -pub trait SearchEngine: Send + Sync + 'static { +pub(crate) trait SearchEngine: Send + Sync + 'static { async fn full_query( &mut self, state: &SearchState, diff --git a/crates/turtle/src/command/client/search/engines/daemon.rs b/crates/turtle/src/command/client/search/engines/daemon.rs index b1299c02..df5ab9f8 100644 --- a/crates/turtle/src/command/client/search/engines/daemon.rs +++ b/crates/turtle/src/command/client/search/engines/daemon.rs @@ -16,7 +16,7 @@ use uuid::Uuid; use super::{SearchEngine, SearchState}; use crate::command::client::daemon; -pub struct Search { +pub(crate) struct Search { client: Option<SearchClient>, query_id: u64, settings: Settings, @@ -25,7 +25,7 @@ pub struct Search { } impl Search { - pub fn new(settings: &Settings) -> Self { + pub(crate) fn new(settings: &Settings) -> Self { Search { client: None, query_id: 0, diff --git a/crates/turtle/src/command/client/search/engines/db.rs b/crates/turtle/src/command/client/search/engines/db.rs index 2765faf5..86917a02 100644 --- a/crates/turtle/src/command/client/search/engines/db.rs +++ b/crates/turtle/src/command/client/search/engines/db.rs @@ -13,7 +13,7 @@ use norm::fzf::{FzfParser, FzfV2}; use std::ops::Range; use tracing::{Level, instrument}; -pub struct Search(pub SearchMode); +pub(crate) struct Search(pub(crate) SearchMode); #[async_trait] impl SearchEngine for Search { @@ -60,7 +60,7 @@ impl SearchEngine for Search { } #[instrument(skip_all, level = Level::TRACE, name = "db_highlight_fulltext")] -pub fn get_highlight_indices_fulltext(command: &str, search_input: &str) -> Vec<usize> { +pub(crate) fn get_highlight_indices_fulltext(command: &str, search_input: &str) -> Vec<usize> { let mut ranges = vec![]; let lower_command = command.to_ascii_lowercase(); diff --git a/crates/turtle/src/command/client/search/engines/skim.rs b/crates/turtle/src/command/client/search/engines/skim.rs index 96a6574d..fe2bdea3 100644 --- a/crates/turtle/src/command/client/search/engines/skim.rs +++ b/crates/turtle/src/command/client/search/engines/skim.rs @@ -16,13 +16,13 @@ use uuid; use super::{SearchEngine, SearchState}; -pub struct Search { +pub(crate) struct Search { all_history: Vec<(History, i32)>, engine: SkimMatcherV2, } impl Search { - pub fn new() -> Self { + pub(crate) fn new() -> Self { Search { all_history: vec![], engine: SkimMatcherV2::default(), diff --git a/crates/turtle/src/command/client/search/history_list.rs b/crates/turtle/src/command/client/search/history_list.rs index 4c83d7eb..9d3a60e0 100644 --- a/crates/turtle/src/command/client/search/history_list.rs +++ b/crates/turtle/src/command/client/search/history_list.rs @@ -19,19 +19,19 @@ use ratatui::{ }; use time::OffsetDateTime; -pub struct HistoryHighlighter<'a> { - pub engine: &'a dyn SearchEngine, - pub search_input: &'a str, +pub(crate) struct HistoryHighlighter<'a> { + pub(crate) engine: &'a dyn SearchEngine, + pub(crate) search_input: &'a str, } impl HistoryHighlighter<'_> { - pub fn get_highlight_indices(&self, command: &str) -> Vec<usize> { + pub(crate) fn get_highlight_indices(&self, command: &str) -> Vec<usize> { self.engine .get_highlight_indices(command, self.search_input) } } -pub struct HistoryList<'a> { +pub(crate) struct HistoryList<'a> { history: &'a [History], block: Option<Block<'a>>, inverted: bool, @@ -47,26 +47,26 @@ pub struct HistoryList<'a> { } #[derive(Default)] -pub struct ListState { +pub(crate) struct ListState { offset: usize, selected: usize, max_entries: usize, } impl ListState { - pub fn selected(&self) -> usize { + pub(crate) fn selected(&self) -> usize { self.selected } - pub fn max_entries(&self) -> usize { + pub(crate) fn max_entries(&self) -> usize { self.max_entries } - pub fn offset(&self) -> usize { + pub(crate) fn offset(&self) -> usize { self.offset } - pub fn select(&mut self, index: usize) { + pub(crate) fn select(&mut self, index: usize) { self.selected = index; } } @@ -118,7 +118,7 @@ impl StatefulWidget for HistoryList<'_> { impl<'a> HistoryList<'a> { #[expect(clippy::too_many_arguments)] - pub fn new( + pub(crate) fn new( history: &'a [History], inverted: bool, alternate_highlight: bool, @@ -143,7 +143,7 @@ impl<'a> HistoryList<'a> { } } - pub fn block(mut self, block: Block<'a>) -> Self { + pub(crate) fn block(mut self, block: Block<'a>) -> Self { self.block = Some(block); self } diff --git a/crates/turtle/src/command/client/search/inspector.rs b/crates/turtle/src/command/client/search/inspector.rs index 1ebc4383..a1bf803f 100644 --- a/crates/turtle/src/command/client/search/inspector.rs +++ b/crates/turtle/src/command/client/search/inspector.rs @@ -25,7 +25,7 @@ fn u64_or_zero(num: i64) -> u64 { if num < 0 { 0 } else { num as u64 } } -pub fn draw_commands( +pub(crate) fn draw_commands( f: &mut Frame<'_>, parent: Rect, history: &History, @@ -113,7 +113,7 @@ pub fn draw_commands( f.render_widget(next, commands[2]); } -pub fn draw_stats_table( +pub(crate) fn draw_stats_table( f: &mut Frame<'_>, parent: Rect, history: &History, @@ -285,7 +285,7 @@ fn draw_stats_charts(f: &mut Frame<'_>, parent: Rect, stats: &HistoryStats, them f.render_widget(duration_over_time, layout[2]); } -pub fn draw( +pub(crate) fn draw( f: &mut Frame<'_>, chunk: Rect, history: &History, @@ -302,7 +302,7 @@ pub fn draw( } } -pub fn draw_ultracompact( +pub(crate) fn draw_ultracompact( f: &mut Frame<'_>, chunk: Rect, history: &History, @@ -312,7 +312,7 @@ pub fn draw_ultracompact( draw_commands(f, chunk, history, stats, true, theme); } -pub fn draw_full( +pub(crate) fn draw_full( f: &mut Frame<'_>, chunk: Rect, history: &History, diff --git a/crates/turtle/src/command/client/search/interactive.rs b/crates/turtle/src/command/client/search/interactive.rs index a3d2cb79..380fc33b 100644 --- a/crates/turtle/src/command/client/search/interactive.rs +++ b/crates/turtle/src/command/client/search/interactive.rs @@ -52,7 +52,7 @@ use ratatui::crossterm::event::{ const TAB_TITLES: [&str; 2] = ["Search", "Inspect"]; -pub enum InputAction { +pub(crate) enum InputAction { Accept(usize), AcceptInspecting, Copy(usize), @@ -66,33 +66,33 @@ pub enum InputAction { } #[derive(Clone)] -pub struct InspectingState { +pub(crate) struct InspectingState { current: Option<HistoryId>, next: Option<HistoryId>, previous: Option<HistoryId>, } impl InspectingState { - pub fn move_to_previous(&mut self) { + pub(crate) fn move_to_previous(&mut self) { let previous = self.previous.clone(); self.reset(); self.current = previous; } - pub fn move_to_next(&mut self) { + pub(crate) fn move_to_next(&mut self) { let next = self.next.clone(); self.reset(); self.current = next; } - pub fn reset(&mut self) { + pub(crate) fn reset(&mut self) { self.current = None; self.next = None; self.previous = None; } } -pub fn to_compactness(f: &Frame, settings: &Settings) -> Compactness { +pub(crate) fn to_compactness(f: &Frame, settings: &Settings) -> Compactness { if match settings.style { crate::atuin_client::settings::Style::Auto => f.area().height < 14, crate::atuin_client::settings::Style::Compact => true, @@ -110,7 +110,7 @@ pub fn to_compactness(f: &Frame, settings: &Settings) -> Compactness { #[expect(clippy::struct_field_names)] #[expect(clippy::struct_excessive_bools)] -pub struct State { +pub(crate) struct State { history_count: i64, results_state: ListState, switched_search_mode: bool, @@ -124,7 +124,7 @@ pub struct State { pending_vim_key: Option<char>, original_input_empty: bool, - pub inspecting_state: InspectingState, + pub(crate) inspecting_state: InspectingState, keymaps: KeymapSet, search: SearchState, @@ -133,7 +133,7 @@ pub struct State { } #[derive(Clone, Copy)] -pub enum Compactness { +pub(crate) enum Compactness { Ultracompact, Compact, Full, @@ -231,7 +231,7 @@ impl State { } } - pub fn initialize_keymap_cursor(&mut self, settings: &Settings) { + pub(crate) fn initialize_keymap_cursor(&mut self, settings: &Settings) { match self.keymap_mode { KeymapMode::Emacs => self.set_keymap_cursor(settings, "emacs"), KeymapMode::VimNormal => self.set_keymap_cursor(settings, "vim_normal"), @@ -240,7 +240,7 @@ impl State { } } - pub fn finalize_keymap_cursor(&mut self, settings: &Settings) { + pub(crate) fn finalize_keymap_cursor(&mut self, settings: &Settings) { match settings.keymap_mode_shell { KeymapMode::Emacs => self.set_keymap_cursor(settings, "emacs"), KeymapMode::VimNormal => self.set_keymap_cursor(settings, "vim_normal"), @@ -1433,7 +1433,7 @@ struct Stdout { } impl Stdout { - pub fn new(inline_mode: bool, no_mouse: bool) -> std::io::Result<Self> { + pub(crate) fn new(inline_mode: bool, no_mouse: bool) -> std::io::Result<Self> { terminal::enable_raw_mode()?; let mut writer = TerminalWriter::new()?; @@ -1547,7 +1547,7 @@ fn compute_popup_placement( clippy::too_many_lines, clippy::cognitive_complexity )] -pub async fn history( +pub(crate) async fn history( query: &[String], settings: &Settings, mut db: impl Database, diff --git a/crates/turtle/src/command/client/search/keybindings/actions.rs b/crates/turtle/src/command/client/search/keybindings/actions.rs index ff2ef7de..341b030c 100644 --- a/crates/turtle/src/command/client/search/keybindings/actions.rs +++ b/crates/turtle/src/command/client/search/keybindings/actions.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// All possible actions that can be triggered by a keybinding. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum Action { +pub(crate) enum Action { // Cursor movement CursorLeft, CursorRight, @@ -77,7 +77,7 @@ pub enum Action { impl Action { /// Convert from a kebab-case string. - pub fn from_str(s: &str) -> Result<Self, String> { + pub(crate) fn from_str(s: &str) -> Result<Self, String> { // Handle accept-N and return-selection-N patterns if let Some(rest) = s.strip_prefix("accept-") && let Ok(n) = rest.parse::<u8>() @@ -156,7 +156,7 @@ impl Action { } /// Convert to a kebab-case string. - pub fn as_str(&self) -> String { + pub(crate) fn as_str(&self) -> String { match self { Action::CursorLeft => "cursor-left".to_string(), Action::CursorRight => "cursor-right".to_string(), diff --git a/crates/turtle/src/command/client/search/keybindings/conditions.rs b/crates/turtle/src/command/client/search/keybindings/conditions.rs index 055ae905..f870d9a0 100644 --- a/crates/turtle/src/command/client/search/keybindings/conditions.rs +++ b/crates/turtle/src/command/client/search/keybindings/conditions.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Atomic (leaf) conditions that can be evaluated against state. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum ConditionAtom { +pub(crate) enum ConditionAtom { CursorAtStart, CursorAtEnd, InputEmpty, @@ -28,7 +28,7 @@ pub enum ConditionAtom { /// - `"list-at-start || no-results"` (disjunction) /// - `"(cursor-at-start && !input-empty) || no-results"` (grouping) #[derive(Debug, Clone, PartialEq, Eq)] -pub enum ConditionExpr { +pub(crate) enum ConditionExpr { Atom(ConditionAtom), Not(Box<ConditionExpr>), And(Box<ConditionExpr>, Box<ConditionExpr>), @@ -37,21 +37,21 @@ pub enum ConditionExpr { /// Context needed to evaluate conditions. This is a pure snapshot of state — /// no references to mutable data. -pub struct EvalContext { +pub(crate) struct EvalContext { /// Current cursor position (unicode width units). - pub cursor_position: usize, + pub(crate) cursor_position: usize, /// Width of the input string in unicode width units. - pub input_width: usize, + pub(crate) input_width: usize, /// Byte length of the input string. - pub input_byte_len: usize, + pub(crate) input_byte_len: usize, /// Currently selected index in the results list. - pub selected_index: usize, + pub(crate) selected_index: usize, /// Total number of results. - pub results_len: usize, + pub(crate) results_len: usize, /// Whether the original input (query passed to the TUI) was empty. - pub original_input_empty: bool, + pub(crate) original_input_empty: bool, /// Whether we use a search context of a command from the history. - pub has_context: bool, + pub(crate) has_context: bool, } // --------------------------------------------------------------------------- @@ -60,7 +60,7 @@ pub struct EvalContext { impl ConditionAtom { /// Evaluate this atom against the given context. - pub fn evaluate(&self, ctx: &EvalContext) -> bool { + pub(crate) fn evaluate(&self, ctx: &EvalContext) -> bool { match self { ConditionAtom::CursorAtStart => ctx.cursor_position == 0, ConditionAtom::CursorAtEnd => ctx.cursor_position == ctx.input_width, @@ -77,7 +77,7 @@ impl ConditionAtom { } /// Parse from a kebab-case string. - pub fn from_str(s: &str) -> Result<Self, String> { + pub(crate) fn from_str(s: &str) -> Result<Self, String> { match s { "cursor-at-start" => Ok(ConditionAtom::CursorAtStart), "cursor-at-end" => Ok(ConditionAtom::CursorAtEnd), @@ -93,7 +93,7 @@ impl ConditionAtom { } /// Convert to a kebab-case string. - pub fn as_str(&self) -> &'static str { + pub(crate) fn as_str(&self) -> &'static str { match self { ConditionAtom::CursorAtStart => "cursor-at-start", ConditionAtom::CursorAtEnd => "cursor-at-end", @@ -120,7 +120,7 @@ impl fmt::Display for ConditionAtom { impl ConditionExpr { /// Evaluate this expression against the given context. - pub fn evaluate(&self, ctx: &EvalContext) -> bool { + pub(crate) fn evaluate(&self, ctx: &EvalContext) -> bool { match self { ConditionExpr::Atom(atom) => atom.evaluate(ctx), ConditionExpr::Not(inner) => !inner.evaluate(ctx), @@ -143,17 +143,17 @@ impl From<ConditionAtom> for ConditionExpr { #[expect(dead_code)] impl ConditionExpr { /// Negate this expression: `!self`. - pub fn not(self) -> Self { + pub(crate) fn not(self) -> Self { ConditionExpr::Not(Box::new(self)) } /// Conjoin with another expression: `self && other`. - pub fn and(self, other: ConditionExpr) -> Self { + pub(crate) fn and(self, other: ConditionExpr) -> Self { ConditionExpr::And(Box::new(self), Box::new(other)) } /// Disjoin with another expression: `self || other`. - pub fn or(self, other: ConditionExpr) -> Self { + pub(crate) fn or(self, other: ConditionExpr) -> Self { ConditionExpr::Or(Box::new(self), Box::new(other)) } } @@ -286,7 +286,7 @@ impl<'a> ExprParser<'a> { impl ConditionExpr { /// Parse a condition expression from a string. - pub fn parse(s: &str) -> Result<Self, String> { + pub(crate) fn parse(s: &str) -> Result<Self, String> { let parser = ExprParser::new(s); parser.parse() } diff --git a/crates/turtle/src/command/client/search/keybindings/defaults.rs b/crates/turtle/src/command/client/search/keybindings/defaults.rs index c8401e37..6627c84d 100644 --- a/crates/turtle/src/command/client/search/keybindings/defaults.rs +++ b/crates/turtle/src/command/client/search/keybindings/defaults.rs @@ -49,12 +49,12 @@ fn key(s: &str) -> KeyInput { /// All five keymaps bundled together. #[derive(Debug, Clone)] -pub struct KeymapSet { - pub emacs: Keymap, - pub vim_normal: Keymap, - pub vim_insert: Keymap, - pub inspector: Keymap, - pub prefix: Keymap, +pub(crate) struct KeymapSet { + pub(crate) emacs: Keymap, + pub(crate) vim_normal: Keymap, + pub(crate) vim_insert: Keymap, + pub(crate) inspector: Keymap, + pub(crate) prefix: Keymap, } // --------------------------------------------------------------------------- @@ -101,7 +101,7 @@ fn accept_action(settings: &Settings) -> Action { /// - `ctrl_n_shortcuts` — whether alt or ctrl is used for numeric shortcuts // Keymap builder that enumerates every default binding; not worth splitting. #[expect(clippy::too_many_lines)] -pub fn default_emacs_keymap(settings: &Settings) -> Keymap { +pub(crate) fn default_emacs_keymap(settings: &Settings) -> Keymap { let mut km = Keymap::new(); add_common_bindings(&mut km); @@ -252,7 +252,7 @@ pub fn default_emacs_keymap(settings: &Settings) -> Keymap { // --------------------------------------------------------------------------- /// Build the default vim-normal keymap. -pub fn default_vim_normal_keymap(settings: &Settings) -> Keymap { +pub(crate) fn default_vim_normal_keymap(settings: &Settings) -> Keymap { let mut km = Keymap::new(); add_common_bindings(&mut km); @@ -333,7 +333,7 @@ pub fn default_vim_normal_keymap(settings: &Settings) -> Keymap { /// Build the default vim-insert keymap. This clones the emacs keymap and /// overlays vim-insert-specific bindings (esc → enter normal mode). -pub fn default_vim_insert_keymap(settings: &Settings) -> Keymap { +pub(crate) fn default_vim_insert_keymap(settings: &Settings) -> Keymap { let mut km = default_emacs_keymap(settings); // Override esc and ctrl-[ to enter normal mode instead of exiting @@ -353,7 +353,7 @@ pub fn default_vim_insert_keymap(settings: &Settings) -> Keymap { /// text input, so we build a minimal keymap with only inspector-relevant /// bindings. We respect the user's `keymap_mode` to provide vim-style j/k /// navigation for vim users. -pub fn default_inspector_keymap(settings: &Settings) -> Keymap { +pub(crate) fn default_inspector_keymap(settings: &Settings) -> Keymap { use crate::atuin_client::settings::KeymapMode; let mut km = Keymap::new(); @@ -400,7 +400,7 @@ pub fn default_inspector_keymap(settings: &Settings) -> Keymap { // --------------------------------------------------------------------------- /// Build the default prefix keymap (active after ctrl-a prefix). -pub fn default_prefix_keymap() -> Keymap { +pub(crate) fn default_prefix_keymap() -> Keymap { let mut km = Keymap::new(); km.bind(key("d"), Action::Delete); @@ -476,7 +476,7 @@ fn apply_config_to_keymap(keymap: &mut Keymap, overrides: &HashMap<String, KeyBi impl KeymapSet { /// Build the complete set of default keymaps from settings. - pub fn defaults(settings: &Settings) -> Self { + pub(crate) fn defaults(settings: &Settings) -> Self { KeymapSet { emacs: default_emacs_keymap(settings), vim_normal: default_vim_normal_keymap(settings), @@ -494,7 +494,7 @@ impl KeymapSet { /// overrides are applied per-key. /// - If `[keymap]` is empty/absent, `[keys]` customizes the defaults /// (current behavior for backward compatibility). - pub fn from_settings(settings: &Settings) -> Self { + pub(crate) fn from_settings(settings: &Settings) -> Self { use crate::atuin_client::settings::Keys; if settings.keymap.is_empty() { diff --git a/crates/turtle/src/command/client/search/keybindings/key.rs b/crates/turtle/src/command/client/search/keybindings/key.rs index c2eb31c6..35107a24 100644 --- a/crates/turtle/src/command/client/search/keybindings/key.rs +++ b/crates/turtle/src/command/client/search/keybindings/key.rs @@ -6,17 +6,17 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// A single key press with modifiers (e.g. `ctrl-c`, `alt-f`, `enter`). #[derive(Debug, Clone, PartialEq, Eq, Hash)] #[expect(clippy::struct_excessive_bools)] -pub struct SingleKey { - pub code: KeyCodeValue, - pub ctrl: bool, - pub alt: bool, - pub shift: bool, - pub super_key: bool, +pub(crate) struct SingleKey { + pub(crate) code: KeyCodeValue, + pub(crate) ctrl: bool, + pub(crate) alt: bool, + pub(crate) shift: bool, + pub(crate) super_key: bool, } /// The key code portion of a key press. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub enum KeyCodeValue { +pub(crate) enum KeyCodeValue { Char(char), Enter, Esc, @@ -39,14 +39,14 @@ pub enum KeyCodeValue { /// A key input that may be a single key or a multi-key sequence (e.g. `g g`). #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub enum KeyInput { +pub(crate) enum KeyInput { Single(SingleKey), Sequence(Vec<SingleKey>), } impl SingleKey { /// Convert a crossterm `KeyEvent` into a `SingleKey`. - pub fn from_event(event: &KeyEvent) -> Option<Self> { + pub(crate) fn from_event(event: &KeyEvent) -> Option<Self> { let ctrl = event.modifiers.contains(KeyModifiers::CONTROL); let alt = event.modifiers.contains(KeyModifiers::ALT); let shift = event.modifiers.contains(KeyModifiers::SHIFT); @@ -112,7 +112,7 @@ impl SingleKey { } /// Parse a key string like `"ctrl-c"`, `"alt-f"`, `"enter"`, `"G"`. - pub fn parse(s: &str) -> Result<Self, String> { + pub(crate) fn parse(s: &str) -> Result<Self, String> { let s = s.trim(); let parts: Vec<&str> = s.split('-').collect(); @@ -264,7 +264,7 @@ impl fmt::Display for SingleKey { impl KeyInput { /// Parse a key input string. Supports multi-key sequences separated by spaces /// (e.g. `"g g"`). - pub fn parse(s: &str) -> Result<Self, String> { + pub(crate) fn parse(s: &str) -> Result<Self, String> { let s = s.trim(); // Check for space-separated multi-key sequences // But don't split "space" or modifier combos like "ctrl-a" diff --git a/crates/turtle/src/command/client/search/keybindings/keymap.rs b/crates/turtle/src/command/client/search/keybindings/keymap.rs index 0d362863..c3b93b59 100644 --- a/crates/turtle/src/command/client/search/keybindings/keymap.rs +++ b/crates/turtle/src/command/client/search/keybindings/keymap.rs @@ -7,27 +7,27 @@ use super::key::{KeyInput, SingleKey}; /// A single rule within a keybinding: an optional condition and an action. /// If the condition is `None`, the rule always matches. #[derive(Debug, Clone)] -pub struct KeyRule { - pub condition: Option<ConditionExpr>, - pub action: Action, +pub(crate) struct KeyRule { + pub(crate) condition: Option<ConditionExpr>, + pub(crate) action: Action, } /// A keybinding is an ordered list of rules. The first rule whose condition /// matches (or has no condition) wins. #[derive(Debug, Clone)] -pub struct KeyBinding { - pub rules: Vec<KeyRule>, +pub(crate) struct KeyBinding { + pub(crate) rules: Vec<KeyRule>, } /// A keymap is a collection of keybindings indexed by key input. #[derive(Debug, Clone)] -pub struct Keymap { - pub bindings: HashMap<KeyInput, KeyBinding>, +pub(crate) struct Keymap { + pub(crate) bindings: HashMap<KeyInput, KeyBinding>, } impl KeyRule { /// Create an unconditional rule. - pub fn always(action: Action) -> Self { + pub(crate) fn always(action: Action) -> Self { KeyRule { condition: None, action, @@ -36,7 +36,7 @@ impl KeyRule { /// Create a conditional rule. Accepts any type convertible to `ConditionExpr`, /// including bare `ConditionAtom` values. - pub fn when(condition: impl Into<ConditionExpr>, action: Action) -> Self { + pub(crate) fn when(condition: impl Into<ConditionExpr>, action: Action) -> Self { KeyRule { condition: Some(condition.into()), action, @@ -46,39 +46,39 @@ impl KeyRule { impl KeyBinding { /// Create a simple (unconditional) binding. - pub fn simple(action: Action) -> Self { + pub(crate) fn simple(action: Action) -> Self { KeyBinding { rules: vec![KeyRule::always(action)], } } /// Create a conditional binding from a list of rules. - pub fn conditional(rules: Vec<KeyRule>) -> Self { + pub(crate) fn conditional(rules: Vec<KeyRule>) -> Self { KeyBinding { rules } } } impl Keymap { /// Create an empty keymap. - pub fn new() -> Self { + pub(crate) fn new() -> Self { Keymap { bindings: HashMap::new(), } } /// Bind a key input to a simple (unconditional) action. - pub fn bind(&mut self, key: KeyInput, action: Action) { + pub(crate) fn bind(&mut self, key: KeyInput, action: Action) { self.bindings.insert(key, KeyBinding::simple(action)); } /// Bind a key input to a conditional set of rules. - pub fn bind_conditional(&mut self, key: KeyInput, rules: Vec<KeyRule>) { + pub(crate) fn bind_conditional(&mut self, key: KeyInput, rules: Vec<KeyRule>) { self.bindings.insert(key, KeyBinding::conditional(rules)); } /// Resolve a key input to an action given the current evaluation context. /// Returns `None` if the key has no binding or no rule's condition matches. - pub fn resolve(&self, key: &KeyInput, ctx: &EvalContext) -> Option<Action> { + pub(crate) fn resolve(&self, key: &KeyInput, ctx: &EvalContext) -> Option<Action> { let binding = self.bindings.get(key)?; for rule in &binding.rules { match &rule.condition { @@ -92,7 +92,7 @@ impl Keymap { /// Check if any binding starts with the given single key as the first key /// of a multi-key sequence. Used to detect pending multi-key sequences. - pub fn has_sequence_starting_with(&self, prefix: &SingleKey) -> bool { + pub(crate) fn has_sequence_starting_with(&self, prefix: &SingleKey) -> bool { self.bindings.keys().any(|ki| match ki { KeyInput::Sequence(keys) => keys.first() == Some(prefix), KeyInput::Single(_) => false, @@ -101,7 +101,7 @@ impl Keymap { /// Merge another keymap into this one. Keys from `other` override keys in `self`. #[expect(dead_code)] - pub fn merge(&mut self, other: &Keymap) { + pub(crate) fn merge(&mut self, other: &Keymap) { for (key, binding) in &other.bindings { self.bindings.insert(key.clone(), binding.clone()); } diff --git a/crates/turtle/src/command/client/search/keybindings/mod.rs b/crates/turtle/src/command/client/search/keybindings/mod.rs index 3b6eb2b2..cdca0406 100644 --- a/crates/turtle/src/command/client/search/keybindings/mod.rs +++ b/crates/turtle/src/command/client/search/keybindings/mod.rs @@ -1,14 +1,14 @@ -pub mod actions; -pub mod conditions; -pub mod defaults; -pub mod key; -pub mod keymap; +pub(crate) mod actions; +pub(crate) mod conditions; +pub(crate) mod defaults; +pub(crate) mod key; +pub(crate) mod keymap; -pub use actions::Action; +pub(crate) use actions::Action; #[expect(unused_imports)] -pub use conditions::{ConditionAtom, ConditionExpr, EvalContext}; -pub use defaults::KeymapSet; +pub(crate) use conditions::{ConditionAtom, ConditionExpr, EvalContext}; +pub(crate) use defaults::KeymapSet; #[expect(unused_imports)] -pub use key::{KeyCodeValue, KeyInput, SingleKey}; +pub(crate) use key::{KeyCodeValue, KeyInput, SingleKey}; #[expect(unused_imports)] -pub use keymap::{KeyBinding, KeyRule, Keymap}; +pub(crate) use keymap::{KeyBinding, KeyRule, Keymap}; diff --git a/crates/turtle/src/command/client/server.rs b/crates/turtle/src/command/client/server.rs index 7de27551..4c2036d8 100644 --- a/crates/turtle/src/command/client/server.rs +++ b/crates/turtle/src/command/client/server.rs @@ -10,7 +10,7 @@ use eyre::{Context, Result, eyre}; #[derive(Subcommand, Clone, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Start the server Start { /// The host address to bind @@ -28,7 +28,7 @@ pub enum Cmd { impl Cmd { #[expect(clippy::too_many_lines)] - pub async fn run(self) -> Result<()> { + pub(crate) async fn run(self) -> Result<()> { match self { Cmd::Start { host, port } => { let settings = Settings::new().wrap_err("could not load server settings")?; diff --git a/crates/turtle/src/command/client/setup.rs b/crates/turtle/src/command/client/setup.rs index b32ceb97..3231b6ec 100644 --- a/crates/turtle/src/command/client/setup.rs +++ b/crates/turtle/src/command/client/setup.rs @@ -5,7 +5,7 @@ use eyre::Result; use std::io::{self, Write}; use toml_edit::{DocumentMut, value}; -pub async fn run(_settings: &Settings) -> Result<()> { +pub(crate) async fn run(_settings: &Settings) -> Result<()> { let enable_ai = prompt( "Atuin AI", "This will enable command generation and other AI features via the question mark key", @@ -60,7 +60,7 @@ pub async fn run(_settings: &Settings) -> Result<()> { Ok(()) } -pub fn prompt(feature: &str, description: &str, note: Option<&str>) -> Result<bool> { +pub(crate) fn prompt(feature: &str, description: &str, note: Option<&str>) -> Result<bool> { println!( "> Enable {feature}?", feature = feature.bold().bright_blue() diff --git a/crates/turtle/src/command/client/stats.rs b/crates/turtle/src/command/client/stats.rs index fc10e949..98401cd3 100644 --- a/crates/turtle/src/command/client/stats.rs +++ b/crates/turtle/src/command/client/stats.rs @@ -25,7 +25,7 @@ fn parse_ngram_size(s: &str) -> Result<usize, String> { #[derive(Parser, Debug)] #[command(infer_subcommands = true)] -pub struct Cmd { +pub(crate) struct Cmd { /// Compute statistics for the specified period, leave blank for statistics since the beginning. See [this](https://docs.atuin.sh/reference/stats/) for more details. period: Vec<String>, @@ -39,7 +39,7 @@ pub struct Cmd { } impl Cmd { - pub async fn run(&self, db: &impl Database, settings: &Settings, theme: &Theme) -> Result<()> { + pub(crate) async fn run(&self, db: &impl Database, settings: &Settings, theme: &Theme) -> Result<()> { let context = current_context().await?; let words = if self.period.is_empty() { String::from("all") diff --git a/crates/turtle/src/command/client/store.rs b/crates/turtle/src/command/client/store.rs index dfa3b66c..3e9355b5 100644 --- a/crates/turtle/src/command/client/store.rs +++ b/crates/turtle/src/command/client/store.rs @@ -22,7 +22,7 @@ mod verify; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Print the current status of the record store Status, @@ -48,7 +48,7 @@ pub enum Cmd { } impl Cmd { - pub async fn run( + pub(crate) async fn run( &self, settings: &Settings, database: &dyn Database, @@ -69,7 +69,7 @@ impl Cmd { } } - pub async fn status(&self, store: SqliteStore) -> Result<()> { + pub(crate) async fn status(&self, store: SqliteStore) -> Result<()> { let host_id = Settings::host_id().await?; let offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC); diff --git a/crates/turtle/src/command/client/store/pull.rs b/crates/turtle/src/command/client/store/pull.rs index c9c9c379..6b709a64 100644 --- a/crates/turtle/src/command/client/store/pull.rs +++ b/crates/turtle/src/command/client/store/pull.rs @@ -11,24 +11,24 @@ use crate::atuin_client::{ }; #[derive(Args, Debug)] -pub struct Pull { +pub(crate) struct Pull { /// The tag to push (eg, 'history'). Defaults to all tags #[arg(long, short)] - pub tag: Option<String>, + pub(crate) tag: Option<String>, /// Force push records /// This will first wipe the local store, and then download all records from the remote #[arg(long, default_value = "false")] - pub force: bool, + pub(crate) force: bool, /// Page Size /// How many records to download at once. Defaults to 100 #[arg(long, default_value = "100")] - pub page: u64, + pub(crate) page: u64, } impl Pull { - pub async fn run( + pub(crate) async fn run( &self, settings: &Settings, store: SqliteStore, diff --git a/crates/turtle/src/command/client/store/purge.rs b/crates/turtle/src/command/client/store/purge.rs index f7996c4b..3ed55787 100644 --- a/crates/turtle/src/command/client/store/purge.rs +++ b/crates/turtle/src/command/client/store/purge.rs @@ -8,10 +8,10 @@ use crate::atuin_client::{ }; #[derive(Args, Debug)] -pub struct Purge {} +pub(crate) struct Purge {} impl Purge { - pub async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { println!("Purging local records that cannot be decrypted"); let key = load_key(settings)?; diff --git a/crates/turtle/src/command/client/store/push.rs b/crates/turtle/src/command/client/store/push.rs index 724dfbef..042ad201 100644 --- a/crates/turtle/src/command/client/store/push.rs +++ b/crates/turtle/src/command/client/store/push.rs @@ -12,29 +12,29 @@ use crate::atuin_client::{ }; #[derive(Args, Debug)] -pub struct Push { +pub(crate) struct Push { /// The tag to push (eg, 'history'). Defaults to all tags #[arg(long, short)] - pub tag: Option<String>, + pub(crate) tag: Option<String>, /// The host to push, in the form of a UUID host ID. Defaults to the current host. #[arg(long)] - pub host: Option<Uuid>, + pub(crate) host: Option<Uuid>, /// Force push records /// This will override both host and tag, to be all hosts and all tags. First clear the remote store, then upload all of the /// local store #[arg(long, default_value = "false")] - pub force: bool, + pub(crate) force: bool, /// Page Size /// How many records to upload at once. Defaults to 100 #[arg(long, default_value = "100")] - pub page: u64, + pub(crate) page: u64, } impl Push { - pub async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { let host_id = Settings::host_id().await?; if self.force { diff --git a/crates/turtle/src/command/client/store/rebuild.rs b/crates/turtle/src/command/client/store/rebuild.rs index 80e201c2..0959b74e 100644 --- a/crates/turtle/src/command/client/store/rebuild.rs +++ b/crates/turtle/src/command/client/store/rebuild.rs @@ -10,12 +10,12 @@ use crate::atuin_client::{ }; #[derive(Args, Debug)] -pub struct Rebuild { - pub tag: String, +pub(crate) struct Rebuild { + pub(crate) tag: String, } impl Rebuild { - pub async fn run( + pub(crate) async fn run( &self, settings: &Settings, store: SqliteStore, diff --git a/crates/turtle/src/command/client/store/rekey.rs b/crates/turtle/src/command/client/store/rekey.rs index e63be447..3472222f 100644 --- a/crates/turtle/src/command/client/store/rekey.rs +++ b/crates/turtle/src/command/client/store/rekey.rs @@ -10,13 +10,13 @@ use crate::atuin_client::{ }; #[derive(Args, Debug)] -pub struct Rekey { +pub(crate) struct Rekey { /// The new key to use for encryption. Omit for a randomly-generated key key: Option<String>, } impl Rekey { - pub async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { let key = if let Some(key) = self.key.clone() { println!("Re-encrypting store with specified key"); diff --git a/crates/turtle/src/command/client/store/verify.rs b/crates/turtle/src/command/client/store/verify.rs index 5aa1dc70..e91addcf 100644 --- a/crates/turtle/src/command/client/store/verify.rs +++ b/crates/turtle/src/command/client/store/verify.rs @@ -8,10 +8,10 @@ use crate::atuin_client::{ }; #[derive(Args, Debug)] -pub struct Verify {} +pub(crate) struct Verify {} impl Verify { - pub async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { + pub(crate) async fn run(&self, settings: &Settings, store: SqliteStore) -> Result<()> { println!("Verifying local store can be decrypted with the current key"); let key = load_key(settings)?; diff --git a/crates/turtle/src/command/client/sync.rs b/crates/turtle/src/command/client/sync.rs index a4839b5f..8d7cb50a 100644 --- a/crates/turtle/src/command/client/sync.rs +++ b/crates/turtle/src/command/client/sync.rs @@ -15,7 +15,7 @@ use crate::command::client::account; #[derive(Subcommand, Debug)] #[command(infer_subcommands = true)] -pub enum Cmd { +pub(crate) enum Cmd { /// Sync with the configured server Sync { /// Force re-download everything @@ -40,7 +40,7 @@ pub enum Cmd { } impl Cmd { - pub async fn run( + pub(crate) async fn run( self, settings: Settings, db: &impl Database, diff --git a/crates/turtle/src/command/client/sync/status.rs b/crates/turtle/src/command/client/sync/status.rs index 00088b59..cb0d86e4 100644 --- a/crates/turtle/src/command/client/sync/status.rs +++ b/crates/turtle/src/command/client/sync/status.rs @@ -3,7 +3,7 @@ use crate::atuin_client::{api_client, settings::Settings}; use colored::Colorize; use eyre::{Result, bail}; -pub async fn run(settings: &Settings) -> Result<()> { +pub(crate) async fn run(settings: &Settings) -> Result<()> { if !settings.logged_in().await? { bail!("You are not logged in to a sync server - cannot show sync status"); } diff --git a/crates/turtle/src/command/client/wrapped.rs b/crates/turtle/src/command/client/wrapped.rs index 694157c2..5e41657e 100644 --- a/crates/turtle/src/command/client/wrapped.rs +++ b/crates/turtle/src/command/client/wrapped.rs @@ -163,7 +163,7 @@ impl WrappedStats { } } -pub fn print_wrapped_header(year: i32) { +pub(crate) fn print_wrapped_header(year: i32) { let reset = ResetColor; let bold = SetAttribute(crossterm::style::Attribute::Bold); @@ -266,7 +266,7 @@ fn print_fun_facts(wrapped_stats: &WrappedStats, stats: &Stats, year: i32) { println!(); } -pub async fn run( +pub(crate) async fn run( year: Option<i32>, db: &impl Database, settings: &Settings, diff --git a/crates/turtle/src/command/contributors.rs b/crates/turtle/src/command/contributors.rs index 452fd335..b2a41522 100644 --- a/crates/turtle/src/command/contributors.rs +++ b/crates/turtle/src/command/contributors.rs @@ -1,5 +1,5 @@ static CONTRIBUTORS: &str = include_str!("CONTRIBUTORS"); -pub fn run() { +pub(crate) fn run() { println!("\n{CONTRIBUTORS}"); } diff --git a/crates/turtle/src/command/external.rs b/crates/turtle/src/command/external.rs index e1f0cddd..a5daea21 100644 --- a/crates/turtle/src/command/external.rs +++ b/crates/turtle/src/command/external.rs @@ -10,7 +10,7 @@ use eyre::Result; use crate::Atuin; -pub fn run(args: &[String]) -> Result<()> { +pub(crate) fn run(args: &[String]) -> Result<()> { let subcommand = &args[0]; let bin = format!("atuin-{subcommand}"); let mut cmd = Command::new(&bin); diff --git a/crates/turtle/src/command/gen_completions.rs b/crates/turtle/src/command/gen_completions.rs index 10d4f689..7cc697d4 100644 --- a/crates/turtle/src/command/gen_completions.rs +++ b/crates/turtle/src/command/gen_completions.rs @@ -9,7 +9,7 @@ use eyre::Result; // into one command. #[derive(Debug, Clone, ValueEnum)] #[value(rename_all = "lower")] -pub enum GenShell { +pub(crate) enum GenShell { Bash, Elvish, Fish, @@ -49,7 +49,7 @@ impl Generator for GenShell { } #[derive(Debug, Parser)] -pub struct Cmd { +pub(crate) struct Cmd { /// Set the shell for generating completions #[arg(long, short)] shell: GenShell, @@ -60,7 +60,7 @@ pub struct Cmd { } impl Cmd { - pub fn run(self) -> Result<()> { + pub(crate) fn run(self) -> Result<()> { let Cmd { shell, out_dir } = self; let mut cli = crate::Atuin::command(); diff --git a/crates/turtle/src/command/mod.rs b/crates/turtle/src/command/mod.rs index e58bfe72..5d5d839e 100644 --- a/crates/turtle/src/command/mod.rs +++ b/crates/turtle/src/command/mod.rs @@ -16,7 +16,7 @@ mod external; #[derive(Subcommand)] #[command(infer_subcommands = true)] #[expect(clippy::large_enum_variant)] -pub enum AtuinCmd { +pub(crate) enum AtuinCmd { #[cfg(feature = "client")] #[command(flatten)] Client(client::Cmd), @@ -39,7 +39,7 @@ pub enum AtuinCmd { } impl AtuinCmd { - pub fn run(self) -> Result<()> { + pub(crate) fn run(self) -> Result<()> { #[cfg(not(windows))] { // set umask before we potentially open/create files |
