Crate convertx

source
Expand description

§convertx

A simple unit-conversion CLI supporting many unit types such as

  • bytes
  • time
  • length
  • temperature
  • mass
  • data rate,
  • area, volume,
  • speed
  • pressure
  • more

§Installation

Simply put the following in your Cargo.toml.

[dependencies]
convertx = "0.1.0"

Or use cargo add convertx

§Usage

convertx <SUBCOMMAND> [OPTIONS]

§Examples

Convert 1024 bytes to megabytes:

convertx bytes 1024 --megabytes
# Output: 1024 bytes = 0.00 MB
 
convertx bytes 1024 -m
# Output: 1024 bytes = 0.00 MB

Convert 3600 seconds to human-readable time:

convertx time 3600 --human-readable
# Output: 3600 seconds = 1h 0m 0s
 
convertx time 3600 -h
# Output: 3600 seconds = 1h 0m 0s

Convert 1 kilometer to feet:

convertx length 1 --from kilometers --to feet
# Output: 1.0000 kilometers = 3280.8400 feet
 
convertx length 10 -f kilometers -t feet
# Output: 10.0000 kilometers = 32800.8400 feet

Convert 100 Fahrenheit to Celsius:

convertx temperature 100 --from F --to C
# Output: 100.00°F = 37.78°C

Run with --help to see all supported subcommands and options.

Macros§

  • Macro for quickly defining enums with string variants and utility implementations.

Enums§

Constants§

  • Constant: Number of bits per second in one megabit per second.
  • Constant: Number of feet in a meter.
  • Constant: Number of inches in a meter.
  • Constant: Zero-offset for Kelvin scale.
  • KG_IN_LB 🔒
    Constant: Number of kilograms in one pound.
  • OZ_IN_KG 🔒
    Constant: Number of ounces in one kilogram.

Functions§