minmax-cli 0.1.0-beta.1

programs computing min and max argument values
# min / max cli programs

[![Version](https://img.shields.io/crates/v/minmax-cli.svg)](https://crates.io/crates/minmax-cli)
[![License](https://img.shields.io/crates/l/minmax-cli)](https://unlicense.org)
[![MSRV](https://img.shields.io/crates/msrv/minmax-cli?logo=rust&label=MSRV&labelColor=orange)](https://blog.rust-lang.org/2022/05/19/Rust-1.61.0/)
[![Safe Rust](https://img.shields.io/badge/Rust-safe-brightgreen.svg)](https://doc.rust-lang.org/nomicon/meet-safe-and-unsafe.html)
[![Dependency status](https://deps.rs/repo/gitlab/hsn10/minmax-cli/status.svg)](https://deps.rs/repo/gitlab/hsn10/minmax-cli)
[![Downloads](https://img.shields.io/crates/d/minmax-cli)](https://crates.io/crates/minmax-cli/versions)
[![](https://tokei.rs/b1/gitlab/hsn10/minmax-cli?category=code)](https://github.com/XAMPPRocky/tokei)


A small Rust command‑line tool 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.

## 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**.
- Provides version and help output.
- Returns meaningful exit codes for different error conditions.

---

## Usage


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

### Options


- `-v`  
  Print program version and exit.
- `-?`  
  Show help message.
- `-a`  
  Compare numbers by their **absolute value** instead of their raw value.

### Positional Arguments


- One or more numeric values (`f64`).
- All values must be finite and valid.
- 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 convert all numbers to their absolute values (`-a`).
4. Find the index of the smallest comparable number.
5. Print the **original** number at that index.

### 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 10 foo 2
Error parsing 'foo': invalid float literal
```

### MSRV


*min* and *max* cli programs needs Rust [version 1.61](https://blog.rust-lang.org/2022/05/19/Rust-1.61.0/).

## License


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

This code can be used under terms of [CC0-1.0](https://creativecommons.org/publicdomain/zero/1.0/) or
the [Unlicense](https://unlicense.org).

![Unlicense logo](https://unlicense.org/pd-icon.png)