#[cfg(target_os = "macos")]
pub fn launchd_plist_path() -> std::path::PathBuf {
dirs::home_dir()
.unwrap_or_else(|| std::path::PathBuf::from("/tmp"))
.join("Library/LaunchAgents/com.collet.remote.plist")
}
#[cfg(not(target_os = "macos"))]
pub fn launchd_plist_path() -> std::path::PathBuf {
std::path::PathBuf::from("/dev/null/com.collet.remote.plist")
}
#[cfg(target_os = "linux")]
pub fn systemd_unit_path() -> std::path::PathBuf {
dirs::home_dir()
.unwrap_or_else(|| std::path::PathBuf::from("/tmp"))
.join(".config/systemd/user/collet-remote.service")
}
pub fn read_password_line() -> anyhow::Result<String> {
let line = rpassword::read_password()
.map_err(|e| crate::common::AgentError::Config(format!("Failed to read input: {e}")))?;
Ok(line.trim().to_string())
}
pub fn open_url(url: &str) -> std::io::Result<()> {
#[cfg(target_os = "macos")]
{
std::process::Command::new("open").arg(url).spawn()?;
}
#[cfg(target_os = "linux")]
{
std::process::Command::new("xdg-open").arg(url).spawn()?;
}
#[cfg(target_os = "windows")]
{
std::process::Command::new("cmd")
.args(["/C", "start", url])
.spawn()?;
}
Ok(())
}