Adds from_str

This commit is contained in:
Thomas Forgione 2019-12-12 11:53:51 +01:00
parent ce15d374fb
commit 07dc60cc79
No known key found for this signature in database
GPG Key ID: BFD17A2D71B3B5E7
1 changed files with 4 additions and 2 deletions

View File

@ -16,8 +16,11 @@ pub enum Os {
impl Os {
pub fn detect() -> Option<Os> {
let lsb_release = lsb_release().unwrap();
Os::from_str(lsb_release.trim())
}
match lsb_release.trim() {
pub fn from_str(os: &str) -> Option<Os> {
match os {
"archlinux" | "Arch Linux" | "arch" | "Arch" | "archarm" => Some(Os::ArchLinux),
"Debian" => Some(Os::Debian),
"ManjaroLinux" => Some(Os::Manjaro),
@ -27,7 +30,6 @@ impl Os {
_ => None,
}
}
pub fn ascii_logo(self) -> &'static str {