minmax-cli 0.1.0-beta.4

programs computing min and max argument values
minmax-cli-0.1.0-beta.4 is not a library.

min / max cli programs

Version License MSRV Safe Rust Dependency status Downloads

Two small Rust command‑line tools that reads numeric arguments, validates them, and prints the value with the lowest / highest comparable magnitude.

The comparison can be done either on the raw numbers or on their absolute values. Optionally, absolute value of selected number can be printed.

Features

  • Accepts any number of positional arguments and parses them as f64.
  • Rejects invalid input, including:
    • Non‑numeric values
    • NaN
    • +∞ or −∞
  • Supports selecting the minimum by absolute value.
  • Supports printing absolute value of returned number.
  • Provides version and help output.
  • Returns meaningful exit codes for different error conditions.

Usage

min|max [-v | -?] | [-a | -A] <number> ...

Options

  • -v Print program version and exit.
  • -? Show help message.
  • -a Compare numbers by their absolute value instead of their raw value.
  • -A Print absolute value of returned number. Implies -a.

Positional Arguments

  • One or more numeric values (f64).
  • All values must be finite and valid floating point numbers.
  • If any argument fails validation, the program exits with an error code.

Behavior

Normal Operation

  1. Parse all positional arguments as floating‑point numbers.
  2. Reject any argument that:
    • Cannot be parsed
    • Is NaN
    • Is infinite
  3. Optionally compare all numbers by their absolute values (-a).
  4. Find the index of the smallest comparable number.
  5. Print the original number at that index, unless (-A) is used. In that case print absolute value of number.

Exit Codes

Code Meaning
0 Success
1 No numeric arguments provided
2 One or more arguments failed to parse or were invalid

Example

$ min 5 -3 9
-3
$ min -a 5 -3 9 1
1
$ min -a -20 34 566 -105
-20
$ min -A -20 34 566 -105
20
$ min 10 foo 2
Error parsing 'foo': invalid float literal

MSRV

min and max cli programs needs Rust version 1.61.

License

This is free and unencumbered software released into the public domain.

This code can be used under terms of CC0-1.0 or the Unlicense.

Unlicense logo