#accounting #journal #formatter #hledger

bin+lib hledger-fmt

An opinionated hledger's journal files formatter

7 releases

new 0.2.3 Jan 13, 2025
0.2.2 Jan 13, 2025
0.2.1 Nov 13, 2024
0.2.0 Oct 18, 2024
0.1.4 Sep 28, 2024

#61 in Finance

Download history 362/week @ 2024-09-25 31/week @ 2024-10-02 9/week @ 2024-10-09 186/week @ 2024-10-16 8/week @ 2024-10-23 2/week @ 2024-10-30 4/week @ 2024-11-06 119/week @ 2024-11-13 10/week @ 2024-11-20 1/week @ 2024-12-04 1/week @ 2024-12-11 52/week @ 2025-01-08

52 downloads per month

MIT license

110KB
2.5K SLoC

hledger-fmt

Crates.io License Tests

An opinionated hledger's journal files formatter.

Installation

Crates.io downloads GitHub downloads

Standalone pre-built binaries

Download standalone pre-built binaries from releases page.

Cargo binaries

Install from pre-built binaries using cargo-binstall:

cargo binstall hledger-fmt

Build from source

Build from source using cargo:

cargo install hledger-fmt

pre-commit

Use it with pre-commit by adding the hook to your .pre-commit-config.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:

{
  "customLocalFormatters.formatters": [
    {
      "command": "hledger-fmt - --no-diff",
      "languages": ["hledger"]
    }
  ]
}

To format on save:

{
  "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.

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.

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.

Dependencies

~1.1–7.5MB
~54K SLoC