Beancount.Engine.CLI (beancount_ex v0.6.0)

Copy Markdown View Source

The default engine: a thin wrapper around the Beancount bean-check and bean-query CLI tools.

This is the behavioral oracle. Rendering is delegated to Beancount.Renderer, checking to Beancount.Checker (shells out to bean-check), and queries to Beancount.Query (shells out to bean-query).

The native Beancount.Engine.Elixir implements the same Beancount.Engine behaviour and is validated against this oracle.

Summary

Functions

Validate .bean text via bean-check.

Validate a .bean file on disk via bean-check.

Run a BQL query via bean-query.

Render directives to .bean text via Beancount.Renderer.

Functions

check(text)

Validate .bean text via bean-check.

Examples

text = "2026-01-01 open Assets:Bank USD\n"

if Beancount.Checker.available?() do
  {:ok, %Beancount.Result{status: :ok}} = Beancount.Engine.CLI.check(text)
end

check_file(path)

Validate a .bean file on disk via bean-check.

Examples

path = Path.join(System.tmp_dir!(), "cli_check.bean")
File.write!(path, "2026-01-01 open Assets:Bank USD\n")

if Beancount.Checker.available?() do
  {:ok, _} = Beancount.Engine.CLI.check_file(path)
end

query(text, bql)

Run a BQL query via bean-query.

Examples

text = "2026-01-01 open Assets:Bank USD\n"

if Beancount.Query.available?() do
  {:ok, _} = Beancount.Engine.CLI.query(text, "SELECT account GROUP BY account")
end

render(directives)

Render directives to .bean text via Beancount.Renderer.

Examples

iex> Beancount.Engine.CLI.render([Beancount.open(~D[2026-01-01], "Assets:Bank", ["USD"])])
"2026-01-01 open Assets:Bank USD\n"