28 releases (stable)

✓ Uses Rust 2018 edition

2.0.6 May 23, 2020
2.0.2 Mar 14, 2020
1.3.3 Jan 24, 2020
1.2.0 Dec 11, 2019
0.4.0 Nov 12, 2017

#5 in Operating systems

Download history 6540/week @ 2020-02-09 5543/week @ 2020-02-16 6026/week @ 2020-02-23 5936/week @ 2020-03-01 8427/week @ 2020-03-08 5874/week @ 2020-03-15 4808/week @ 2020-03-22 4643/week @ 2020-03-29 6687/week @ 2020-04-05 5845/week @ 2020-04-12 5848/week @ 2020-04-19 6962/week @ 2020-04-26 6296/week @ 2020-05-03 7483/week @ 2020-05-10 6923/week @ 2020-05-17 6967/week @ 2020-05-24

27,138 downloads per month
Used in 37 crates (9 directly)

MIT license

58KB
1.5K SLoC

os_info

Status: CI codecov

Project info: Docs.rs Latest Version License

Project details: LoC rust 1.41+ required dependency status

Overview

This project consists of two parts: the library that can be used to detect the operating system type (including version and bitness) and the command line tool that uses the library.

Library (os_info)

os_info usage

To use this crate, add os_info as a dependency to your project's Cargo.toml:

[dependencies]
os_info = "2.0.6"

This project has serde as an optional dependency, so if you don't need it, then you can speed up compilation disabling it:

[dependencies]
os_info = { version = "2.0.6", default-features = false }

Example

let info = os_info::get();

// Print full information:
println!("OS information: {}", info);

// Print information separately:
println!("Type: {}", info.os_type());
println!("Version: {}", info.version());
println!("Bitness: {}", info.bitness());

Command line tool (os_info_cli)

A simple wrapper around the os_info library.

Installation

This tool can be installed using the following cargo command:

cargo install os_info_cli

os_info_cli usage

Despite being named os_info_cli during installation, it is actually named os_info. You can use the --help flag to see available options:

os_info --help

Supported operating systems

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

  • Unknown
  • Android
  • Emscripten
  • Linux
  • Redhat
  • RedHatEnterprise
  • Ubuntu
  • Pop!_OS
  • Debian
  • Arch
  • CentOS
  • Fedora
  • Amazon
  • Alpine
  • SUSE Linux Enterprise
  • openSUSE
  • Solus
  • Manjaro
  • Macos
  • Redox
  • Windows

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

License

os_info is licensed under the MIT license. See LICENSE for the details.

Dependencies

~0.6–1.1MB
~25K SLoC