Skip to content
Rust library to detect the operating system type
Rust
Branch: master
Clone or download
Latest commit d0d2aa0 Oct 5, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create PULL_REQUEST_TEMPLATE Apr 21, 2018
src feat: add support for Manjaro Linux Sep 16, 2018
tests feat: add support for Manjaro Linux Sep 16, 2018
.gitignore Initial commit Oct 18, 2015
.travis.yml Update .travis.yml Oct 5, 2018
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.toml Bump version to 2.2.0 Sep 16, 2018
Changelog.md
LICENSE Create LICENSE Oct 18, 2015
README.md

README.md

Build Status

os_type

Rust library to detect the operating system type

Usage

Include this into your Cargo.toml:

[dependencies]
os_type="2.2"

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

You can’t perform that action at this time.