diff options
Diffstat (limited to 'crates/turtle/src/atuin_common/shell.rs')
| -rw-r--r-- | crates/turtle/src/atuin_common/shell.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/crates/turtle/src/atuin_common/shell.rs b/crates/turtle/src/atuin_common/shell.rs index 7f9a7b8f..dbd9b982 100644 --- a/crates/turtle/src/atuin_common/shell.rs +++ b/crates/turtle/src/atuin_common/shell.rs @@ -5,7 +5,7 @@ use sysinfo::{Process, System, get_current_pid}; use thiserror::Error; #[derive(PartialEq)] -pub enum Shell { +pub(crate) enum Shell { Sh, Bash, Fish, @@ -36,7 +36,7 @@ impl std::fmt::Display for Shell { } #[derive(Debug, Error, Serialize)] -pub enum ShellError { +pub(crate) enum ShellError { #[error("shell not supported")] NotSupported, @@ -45,7 +45,7 @@ pub enum ShellError { } impl Shell { - pub fn current() -> Shell { + pub(crate) fn current() -> Shell { let sys = System::new_all(); let process = sys @@ -62,13 +62,13 @@ impl Shell { Shell::from_string(shell.to_string()) } - pub fn from_env() -> Shell { + pub(crate) fn from_env() -> Shell { std::env::var("ATUIN_SHELL").map_or(Shell::Unknown, |shell| { Shell::from_string(shell.trim().to_lowercase()) }) } - pub fn config_file(&self) -> Option<std::path::PathBuf> { + pub(crate) fn config_file(&self) -> Option<std::path::PathBuf> { let mut path = if let Some(base) = directories::BaseDirs::new() { base.home_dir().to_owned() } else { @@ -90,7 +90,7 @@ impl Shell { /// Best-effort attempt to determine the default shell /// This implementation will be different across different platforms /// Caller should ensure to handle Shell::Unknown correctly - pub fn default_shell() -> Result<Shell, ShellError> { + pub(crate) fn default_shell() -> Result<Shell, ShellError> { let sys = System::name().unwrap_or("".to_string()).to_lowercase(); // TODO: Support Linux @@ -118,7 +118,7 @@ impl Shell { )) } - pub fn from_string(name: String) -> Shell { + pub(crate) fn from_string(name: String) -> Shell { match name.as_str() { "bash" => Shell::Bash, "fish" => Shell::Fish, @@ -135,11 +135,11 @@ impl Shell { /// Returns true if the shell is posix-like /// Note that while fish is not posix compliant, it behaves well enough for our current /// featureset that this does not matter. - pub fn is_posixish(&self) -> bool { + pub(crate) fn is_posixish(&self) -> bool { matches!(self, Shell::Bash | Shell::Fish | Shell::Zsh) } - pub fn run_interactive<I, S>(&self, args: I) -> Result<String, ShellError> + pub(crate) fn run_interactive<I, S>(&self, args: I) -> Result<String, ShellError> where I: IntoIterator<Item = S>, S: AsRef<OsStr>, @@ -162,7 +162,7 @@ impl Shell { } } -pub fn shell_name(parent: Option<&Process>) -> String { +pub(crate) fn shell_name(parent: Option<&Process>) -> String { let sys = System::new_all(); let parent = if let Some(parent) = parent { |
