Metadata-Version: 2.4
Name: fguess
Version: 0.1.0
Summary: f-string format spec guesser
Project-URL: Documentation, https://github.com/treyhunner/fguess#readme
Project-URL: Issues, https://github.com/treyhunner/fguess/issues
Project-URL: Source, https://github.com/treyhunner/fguess
Author: Trey Hunner
License-Expression: MIT
License-File: LICENSE.txt
Keywords: cli,f-string,format,format-spec,formatting
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.9
Requires-Dist: strptime-cli
Description-Content-Type: text/markdown

# fguess

[![PyPI - Version](https://img.shields.io/pypi/v/fguess.svg)](https://pypi.org/project/fguess)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fguess.svg)](https://pypi.org/project/fguess)

Like https://pym.dev/format but in your terminal.

Given an example of formatted output, `fguess` guesses the f-string format specification that would produce it.


## Installation

Installing with [`uv tool`](https://docs.astral.sh/uv/concepts/tools/):

```console
uv tool install fguess
```

Installing with [`pipx`](https://pipx.pypa.io):

```console
pipx install fguess
```

You can also install `fguess` globally with `pip`, but I usually recommend installing command-line tools in their own separate environment.


## Usage

Run `fguess` with an example of formatted output to see the format specification that would produce it:

```console
$ fguess '$1,234.56'

Input: '$1,234.56'
----------------------------------------
float    → f"${variable:,.2f}"
           (e.g., variable = 1234.56)

str      → f"${variable}"
           (e.g., variable = '1,234.56')
```

Padded strings and datetimes are recognized too:

```console
$ fguess "2030-01-24 05:45"

Input: '2030-01-24 05:45'
----------------------------------------
datetime → f"{variable:%Y-%m-%d %H:%M}"
           (e.g., variable = datetime.datetime(2030, 1, 24, 5, 45))
```

Remember to quote the string you pass in, since format specifications often include characters your shell would otherwise interpret.

Run `fguess` with no arguments to analyze one string after another until you type `quit`.


## Development

This project uses [uv](https://docs.astral.sh/uv/) and [just](https://just.systems).
Run `just` to see every available task.

```console
$ just test     # run the test suite
$ just check    # format, lint, and test
```

No setup step is needed: `uv` creates the virtual environment and installs dependencies on the first `uv run`.

To run the tests on every supported Python version:

```console
just test-all
```

To see code coverage:

```console
just test-cov
open htmlcov/index.html
```

If you would rather not install `just`, every task is a short `uv` command that you can run directly (check the `justfile` for the commands):

```console
uv run pytest
```


## Releasing

Releases are published to PyPI by GitHub Actions whenever a `v*` tag is pushed.
From an up-to-date `main`:

```console
$ just bump minor              # or patch, or major
$ git commit -am "Version 0.1.0"
$ just release
```

The `release` task refuses to run unless the checks pass, the working tree is clean, and you are on `main`.
It then tags the current version and pushes, which triggers the release workflow.


## License

`fguess` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
