use anyhow::Error;
use crate::{
browsers::WebBrowser,
cli::{CreateArgs, EditArgs},
utils::generate_codename,
};
pub mod linux;
#[allow(unused)]
pub enum OperatingSystem {
Linux,
Windows,
MacOS,
}
impl OperatingSystem {
pub fn get() -> OperatingSystem {
#[cfg(target_os = "linux")]
{
OperatingSystem::Linux
}
#[cfg(target_os = "windows")]
{
OperatingSystem::Windows
}
#[cfg(target_os = "macos")]
{
OperatingSystem::MacOS
}
}
pub fn create_shortcut(self, browser: &WebBrowser, args: CreateArgs) -> Result<String, Error> {
let _codename = generate_codename(&args.name)?;
match self {
OperatingSystem::Linux => linux::create_shortcut(&self, browser, args),
OperatingSystem::Windows => panic!("Windows is not supported yet"),
OperatingSystem::MacOS => panic!("MacOS is not supported yet"),
}
}
pub fn list_webapps(self) -> Result<(), Error> {
match self {
OperatingSystem::Linux => {
linux::list_webapps(&self)?;
Ok(())
}
OperatingSystem::Windows => panic!("Windows is not supported yet"),
OperatingSystem::MacOS => panic!("MacOS is not supported yet"),
}
}
pub fn run_webapp(self, codename: &str) -> Result<(), Error> {
match self {
OperatingSystem::Linux => linux::run_webapp(&self, codename),
OperatingSystem::Windows => panic!("Windows is not supported yet"),
OperatingSystem::MacOS => panic!("MacOS is not supported yet"),
}
}
pub fn edit_webapp(
self,
browser: &WebBrowser,
codename: &str,
args: EditArgs,
) -> Result<(), Error> {
match self {
OperatingSystem::Linux => linux::edit_webapp(&self, browser, codename, args),
OperatingSystem::Windows => panic!("Windows is not supported yet"),
OperatingSystem::MacOS => panic!("MacOS is not supported yet"),
}
}
pub fn update_webapps(self, browser: &WebBrowser) -> Result<(), Error> {
match self {
OperatingSystem::Linux => linux::update_webapps(browser),
OperatingSystem::Windows => panic!("Windows is not supported yet"),
OperatingSystem::MacOS => panic!("MacOS is not supported yet"),
}
}
pub fn delete_webapp(self, browser: &WebBrowser, codename: &str) -> Result<(), Error> {
match self {
OperatingSystem::Linux => linux::delete_webapp(&self, browser, codename),
OperatingSystem::Windows => panic!("Windows is not supported yet"),
OperatingSystem::MacOS => panic!("MacOS is not supported yet"),
}
}
}