29 releases (stable)

2.0.7 Jul 26, 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

#4 in Operating systems

Download history 6077/week @ 2020-04-14 5589/week @ 2020-04-21 7423/week @ 2020-04-28 5720/week @ 2020-05-05 8041/week @ 2020-05-12 6385/week @ 2020-05-19 7733/week @ 2020-05-26 6761/week @ 2020-06-02 7511/week @ 2020-06-09 7055/week @ 2020-06-16 8085/week @ 2020-06-23 8046/week @ 2020-06-30 12045/week @ 2020-07-07 9879/week @ 2020-07-14 10630/week @ 2020-07-21 10132/week @ 2020-07-28

34,469 downloads per month
Used in 45 crates (13 directly)

MIT license

59KB
1.5K SLoC

os_info

Status: CI Coverage

Project info: Docs.rs Latest Version License

Project details: LoC Rust 1.41+ required Dependencies

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.7"

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.7", 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:

  • Alpine Linux
  • Amazon Linux AMI
  • Android
  • Arch Linux
  • CentOS
  • Debian
  • Emscripten
  • Fedora
  • Linux
  • macOS (Mac OS X or OS X)
  • Manjaro
  • openSUSE
  • Oracle Linux
  • Pop!_OS
  • Red Hat Linux
  • Red Hat Enterprise Linux
  • Redox
  • Solus
  • SUSE Linux Enterprise Server
  • Ubuntu
  • Unknown
  • 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
~26K SLoC