use anyhow::Result;
use crate::config::StartupConfig;
use crate::scope::Scope;
pub(crate) trait Platform {
fn exists(&self, config: &StartupConfig, scope: Scope) -> Result<bool>;
fn is_run(&self, config: &StartupConfig, scope: Scope) -> Result<bool>;
fn install(&self, config: &StartupConfig, scope: Scope) -> Result<()>;
fn uninstall(&self, config: &StartupConfig, scope: Scope) -> Result<()>;
fn start(&self, config: &StartupConfig, scope: Scope) -> Result<()>;
fn stop(&self, config: &StartupConfig, scope: Scope) -> Result<()>;
}
#[cfg(target_os = "windows")]
pub(crate) fn current_platform() -> Result<Box<dyn Platform>> {
Ok(Box::new(crate::windows::WindowsStartup))
}
#[cfg(target_os = "linux")]
pub(crate) fn current_platform() -> Result<Box<dyn Platform>> {
Ok(Box::new(crate::linux::LinuxStartup))
}
#[cfg(target_os = "macos")]
pub(crate) fn current_platform() -> Result<Box<dyn Platform>> {
Ok(Box::new(crate::macos::MacosStartup))
}
#[cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))]
pub(crate) fn current_platform() -> Result<Box<dyn Platform>> {
Err(anyhow::anyhow!("当前操作系统不支持开机自启"))
}