Skip to content

Commit

Permalink
feat: add support for FreeBSD and NetBSD
Browse files Browse the repository at this point in the history
Signed-off-by: K.B.Dharun Krishna <[email protected]>
  • Loading branch information
kbdharun committed Oct 29, 2023
1 parent c9cfbcf commit f69f2a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
40 changes: 28 additions & 12 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ pub enum Platform {

#[value(name = "openbsd")]
#[cfg_attr(target_os = "openbsd", default)]
OpenBsd,
OpenBSD,

#[value(name = "freebsd")]
#[cfg_attr(target_os = "freebsd", default)]
FreeBSD,

#[value(name = "netbsd")]
#[cfg_attr(target_os = "netbsd", default)]
NetBSD,

#[cfg_attr(target_os = "windows", default)]
Windows,
Expand All @@ -23,13 +31,15 @@ pub enum Platform {
Android,

#[value(name = "sunos")]
SunOs,
SunOS,

#[cfg_attr(
not(any(
target_os = "linux",
target_os = "macos",
target_os = "openbsd",
target_os = "freebsd",
target_os = "netbsd",
target_os = "windows",
target_os = "android"
)),
Expand All @@ -40,24 +50,30 @@ pub enum Platform {

impl Platform {
pub fn iterator() -> impl Iterator<Item = Platform> {
use self::Platform::{Android, Linux, OpenBsd, OsX, SunOs, Windows};
[Linux, OsX, OpenBsd, Windows, Android, SunOs].into_iter()
use self::Platform::{Android, FreeBSD, Linux, NetBSD, OpenBSD, OsX, SunOS, Windows};
[
Android, FreeBSD, Linux, NetBSD, OpenBSD, OsX, SunOS, Windows,
]
.iter()
.copied()
}
}

// These are the directory names.
impl Display for Platform {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
let platform_str = match self {
Self::Android => "android",
Self::Common => "common",
Self::FreeBSD => "freebsd",
Self::Linux => "linux",
Self::NetBSD => "netbsd",
Self::OsX => "osx",
Self::OpenBsd => "openbsd",
Self::OpenBSD => "openbsd",
Self::SunOS => "sunos",
Self::Windows => "windows",
Self::Android => "android",
Self::SunOs => "sunos",
Self::Common => "common",
}
.fmt(f)
};
write!(f, "{platform_str}")
}
}

Expand Down Expand Up @@ -142,7 +158,7 @@ pub struct Cli {
#[arg(long)]
pub no_raw: bool,

/// Supress status messages.
/// Suppress status messages.
#[arg(short, long)]
pub quiet: bool,

Expand Down
2 changes: 2 additions & 0 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ impl<'a> Cache<'a> {
.into_iter()
.chain(self.list_dir("osx", &lang_dir)?)
.chain(self.list_dir("openbsd", &lang_dir)?)
.chain(self.list_dir("freebsd", &lang_dir)?)
.chain(self.list_dir("netbsd", &lang_dir)?)
.chain(self.list_dir("windows", &lang_dir)?)
.chain(self.list_dir("android", &lang_dir)?)
.chain(self.list_dir("sunos", &lang_dir)?)
Expand Down

0 comments on commit f69f2a5

Please sign in to comment.