Metadata-Version: 2.4
Name: calculator-cli
Version: 1.0.1
Summary: A calculator REPL CLI with mpmath and ECB exchange rates
Project-URL: Repository, https://github.com/alex180500/calculator-cli
Project-URL: Issues, https://github.com/alex180500/calculator-cli/issues
Project-URL: Changelog, https://github.com/alex180500/calculator-cli/releases
Author: Alessandro Romancino
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: calculator,cli,cli-app,exchange-rates,mpmath,python,repl
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Utilities
Requires-Python: >=3.13
Requires-Dist: mpmath>=1.4.1
Description-Content-Type: text/markdown

# calculator-cli

`calculator-cli` opens the standard Python REPL with `mpmath` loaded into the namespace and ECB exchange conversion built in.

## REPL Usage

Normal Python expressions stay normal Python expressions:

```python
1 / 3
2 ** 10
```

The `_` variable is stored as the last result and can be used as in the usual Python REPL.

`mpmath` names are already loaded, so `mpmath` expressions work directly:

```python
sin(pi)
sqrt(2)
quad(lambda x: exp(-x**2), [0, inf])
```

`sin(pi)` is displayed as `0` because the REPL display hook uses `mpmath.chop(...)` before printing.

Exchange helpers are also available:

```python
convert(100, "EUR", "USD")
refresh_exchange()
```

`convert(...)` returns an `mpmath.mpf`, so `_` stays numeric and can be reused in later calculations. In the REPL it is displayed as:

```text
116.84 USD [on 2026-04-13]
```

## Run

```bash
uv run calculator
uv run c
```

Help:

```bash
uv run calculator --help
```

Custom cache directory:

```bash
uv run calculator --cache ./cache
```


## Exchange cache

On every startup the app runs `refresh_exchange()`.

- The cache file is `ecb_rates.json`.
- The file stores the ECB rate date, the local retrieval date, and the currency table.
- If the cache was already retrieved today, no network request is made.
- If today is different, the app fetches the ECB XML feed again and rewrites the cache.

Default cache location:

- Windows: `%LOCALAPPDATA%\calculator-cli\ecb_rates.json`
- Unix-like systems: `${XDG_CACHE_HOME:-~/.cache}/calculator-cli/ecb_rates.json`


## Local Install

```bash
uv sync

uv run calculator
```

## License

This package is distributed under the [Apache-2.0 License](LICENSE).
