https://github.com/mondeja/hledger-fmt
An opinionated hledger's journal files formatter.
https://github.com/mondeja/hledger-fmt
accounting cli format formatter hledger journal ledger pre-commit-hooks rust
Last synced: 6 months ago
JSON representation
An opinionated hledger's journal files formatter.
- Host: GitHub
- URL: https://github.com/mondeja/hledger-fmt
- Owner: mondeja
- License: mit
- Created: 2024-09-27T03:10:08.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-14T14:07:55.000Z (6 months ago)
- Last Synced: 2025-04-15T15:11:59.959Z (6 months ago)
- Topics: accounting, cli, format, formatter, hledger, journal, ledger, pre-commit-hooks, rust
- Language: Rust
- Homepage:
- Size: 101 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# hledger-fmt
[](https://crates.io/crates/hledger-fmt)
[](https://docs.rs/hledger-fmt)
[](https://github.com/mondeja/hledger-fmt/actions)
[](https://github.com/mondeja/hledger-fmt/blob/master/LICENSE)An opinionated [hledger]'s journal files formatter.
## Installation
[](https://crates.io/crates/hledger-fmt)
### Standalone pre-built binaries
Download standalone pre-built binaries from [releases page].
### Cargo binaries
Install from pre-built binaries using [cargo-binstall]:
```sh
cargo binstall hledger-fmt
```### Build from source
Build from source using [cargo]:
```sh
cargo install hledger-fmt
```### pre-commit
Use it with [pre-commit] by adding the hook to your _.pre-commit-config.yaml_:
```yaml
repos:
- repo: https://github.com/mondeja/hledger-fmt
rev: vX.Y.Z
hooks:
# id: hledger-fmt # Use this id to format files in place
- id: hledger-fmt-check # Use this id to check files without formatting
```### VSCode
With hledger-fmt in your PATH, use the [VSCode Custom Local Formatters]
extension. Just install it and add the next configuration to your
_settings.json_:```json
{
"customLocalFormatters.formatters": [
{
"command": "hledger-fmt - --no-diff",
"languages": ["hledger"]
}
]
}
```To format on save:
```json
{
"editor.formatOnSave": true
}
```## Usage
When you don't pass files to format, it reads all the files with
the extensions `.journal`, `.hledger` and `.j` in the current directory
and its subdirectories.```sh
hledger-fmt [OPTIONS] [FILES]...
```To fix them in place, use the `--fix` option:
> [!WARNING]\
> This is a potentially destructive operation. Make sure to make a backup
> of your files before running this command for the first time.```sh
hledger-fmt --fix [FILES]...
```See `hledger-fmt --help` for more information.
## Features
- **`color`** (enabled by default): Build with terminal color support.
- **`auto-color`** (enabled by default): Automatically detects if your terminal
supports colors.[cargo-binstall]: https://github.com/cargo-bins/cargo-binstall
[hledger]: https://hledger.org
[cargo]: https://doc.rust-lang.org/cargo/
[releases page]: https://github.com/mondeja/hledger-fmt/releases
[pre-commit]: https://pre-commit.com
[VSCode Custom Local Formatters]: https://marketplace.visualstudio.com/items?itemName=jkillian.custom-local-formatters