12 releases (4 stable)

2.2.0 Sep 16, 2018
2.0.0 May 19, 2017
1.0.0 May 11, 2017
0.6.0 Feb 7, 2016
0.4.0 Nov 29, 2015
Download history 3728/week @ 2020-03-11 4999/week @ 2020-03-18 4533/week @ 2020-03-25 4323/week @ 2020-04-01 3295/week @ 2020-04-08 3698/week @ 2020-04-15 3604/week @ 2020-04-22 3100/week @ 2020-04-29 5169/week @ 2020-05-06 6100/week @ 2020-05-13 5271/week @ 2020-05-20 5285/week @ 2020-05-27 6188/week @ 2020-06-03 5075/week @ 2020-06-10 6600/week @ 2020-06-17 5322/week @ 2020-06-24

17,071 downloads per month
Used in 67 crates (15 directly)

MIT license

17KB
436 lines

Build Status

os_type

Rust library to detect the operating system type

Usage

Include this into your Cargo.toml:

[dependencies]
os_type="1.0.0"

In your code:

extern crate os_type;
let os = os_type::current_platform();
println!("Type: {:?}", os.os_type);
println!("Version: {}", os.version);

Or to provide different handling on different operating systems:

match os_type::current_platform().os_type {
  os_type::OSType::OSX => {
    println!("This is probably an apple laptop!");
  }
  os_type::OSType::Ubuntu => {
    println!("This is running Ubuntu Linux!");
  }
  _ => {
    println!("I can't tell what system this is.");
  }
}

Right now, the following operating system types can be returned:

  • Unknown
  • Redhat
  • CentOS
  • OSX
  • Ubuntu
  • Debian
  • Arch
  • Manjaro

If you need support for more OS types, I am looking forward to your Pull Request.

Requirements

On Linux based systems this library requires that lsb_release is installed.

Contributing

Bug reports and pull requests are welcome on GitHub. You can find more information about contributing in the CONTRIBUTING.md. This project is intended to be a safe, welcoming space for collaboration and discussion, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

MIT

Dependencies

~1.5MB
~40K SLoC