https://github.com/wakuflair/unit-forge
A flexible, extensible command-line calculator for arithmetic with physical units
https://github.com/wakuflair/unit-forge
Last synced: 3 months ago
JSON representation
A flexible, extensible command-line calculator for arithmetic with physical units
- Host: GitHub
- URL: https://github.com/wakuflair/unit-forge
- Owner: wakuflair
- Created: 2025-06-22T10:38:11.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2025-06-22T11:00:52.000Z (5 months ago)
- Last Synced: 2025-06-22T11:30:47.533Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Unit Forge
Unit Forge is a flexible, extensible command-line calculator for arithmetic with physical units. It allows you to define your own units and categories, perform calculations, and convert between units interactively.
## Features
- Arithmetic with units (e.g., `1 m + 2 cm`, `3 m * 4 m`)
- Custom unit definitions via TOML files
- Derived units and categories (e.g., area, volume, speed)
- Unit conversion (e.g., `1 m >> cm`)
- Variable assignment and reuse
- Error reporting for incompatible or unknown units
## Getting Started
### Usage
- On launch, the CLI loads all `.ud` files from the `unit_definitions/` directory.
- Enter expressions such as:
- `1 m + 2 cm`
- `3 m * 4 m`
- `1 m >> cm` (convert 1 meter to centimeters)
- `x = 5.3 m` (assign variable)
- `x + 2 m`
- `$ * 2` (`$` is a reserved variable holds the last result)
- Supported operators: `+`, `-`, `*`, `/`, `>>` (convert)
- Use parentheses for grouping: `(1 m + 2 m) * 3`
- Press `Ctrl + C` to exit
### Defining Units
Units are defined in TOML-like `.ud` files in the `unit_definitions/` directory. Example:
```toml
[length]
m = { name = "meter", symbol = "m" }
cm = { name = "centimeter", symbol = "cm", factor = 0.01 }
[area]
m2 = { name = "square meter", symbol = "m²", derived = "m * m" }
```
## Project Structure
- `unit-forge-lib/`: Core library for parsing, evaluating, and managing units
- `unit-forge-cli/`: Command-line interface
- `unit_definitions/`: Example and user-defined unit files
## Testing
```powershell
cargo test
```
## License
MIT