Skip to content

Commit

Permalink
;doc: output: edits
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichael committed Oct 18, 2024
1 parent 4cf064e commit 121b648
Showing 1 changed file with 28 additions and 44 deletions.
72 changes: 28 additions & 44 deletions hledger/hledger.m4.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,10 @@ hledger tries to detect ANSI color and text styling support and use it when appr
though currently rather minimally: some reports show negative numbers in red,
and help output uses bold text for emphasis.

You can override this in the usual ways:

- If the `NO_COLOR` environment variable is set, colour will be disabled by default.
- Use the `--color/--colour` option with a `yes`/`always` value,
or `no`/`never`, to force colour on or off.
You can override this in the usual ways.
If the `NO_COLOR` environment variable is set, colour will be disabled by default.
Or you can use the `--color/--colour` option with a `yes`/`always` value,
or `no`/`never`, to force colour on or off.

#### Box-drawing

Expand Down Expand Up @@ -850,54 +849,39 @@ option "operating_currency" "USD"

### SQL output

- This is not yet much used; real-world feedback is welcome.
SQL output is expected to work at least with SQLite, MySQL and Postgres.

- SQL output is expected to work at least with SQLite, MySQL and Postgres.
The SQL statements are expected to be executed in the empty database.
If you already have tables created via SQL output of hledger,
you would probably want to either clear data from these
(via `delete` or `truncate` SQL statements) or `drop` the tables completely
before import; otherwise your postings would be duplicated.

- For SQLite, it will be more useful if you modify the generated `id` field
to be a PRIMARY KEY. Eg:
```
$ hledger print -O sql | sed 's/id serial/id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL/g' | ...
```
For SQLite, it is more useful if you modify the generated `id` field
to be a PRIMARY KEY. Eg:
```
$ hledger print -O sql | sed 's/id serial/id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL/g' | ...
```

- SQL output is structured with the expectations that statements will
be executed in the empty database. If you already have tables created
via SQL output of hledger, you would probably want to either clear tables
of existing data (via `delete` or `truncate` SQL statements) or drop
tables completely as otherwise your postings will be duped.
This is not yet much used; feedback is welcome.

### JSON output

- This is not yet much used; real-world feedback is welcome.
Our JSON is rather large and verbose, since it is a faithful representation of hledger's internal data types.
To understand its structure, read the Haskell type definitions, which are mostly in
<https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Types.hs>.
[hledger-web's OpenAPI specification][openapi.yaml] may also be relevant.

- Our JSON is rather large and verbose, since it is a faithful
representation of hledger's internal data types. To understand the
JSON, read the Haskell type definitions, which are mostly in
<https://github.com/simonmichael/hledger/blob/master/hledger-lib/Hledger/Data/Types.hs>.
[hledger-web's OpenAPI specification][openapi.yaml] may also be relevant.

<!--
- The JSON output from hledger commands is essentially the same as the
JSON served by [hledger-web's JSON API](hledger-web.html#json-api),
but pretty printed, using line breaks and indentation.
Our pretty printer has the ability to elide data in certain cases -
rendering non-strings as if they were strings, or displaying "FOO.."
instead of FOO's full details. This should never happen in hledger's
JSON output; if you see otherwise, please report as a bug.
-->
[openapi.yaml]: https://github.com/simonmichael/hledger/blob/master/hledger-web/config/openapi.yaml

- hledger represents quantities as Decimal values storing up to 255
significant digits, eg for repeating decimals. Such numbers can
arise in practice (from automatically-calculated transaction
prices), and would break most JSON consumers. So in JSON, we show
quantities as simple Numbers with at most 10 decimal places. We
don't limit the number of integer digits, but that part is under
your control.
We hope this approach will not cause problems in practice; if you
find otherwise, please let us know.
(Cf [#1195](https://github.com/simonmichael/hledger/issues/1195))
hledger stores numbers with sometimes up to 255 significant digits.
This is too many digits for most JSON consumers,
so in JSON output we round numbers to at most 10 decimal places.
(We don't limit the number of integer digits.)
If you find this causing problems, please let us know.
Related: [#1195](https://github.com/simonmichael/hledger/issues/1195)

[openapi.yaml]: https://github.com/simonmichael/hledger/blob/master/hledger-web/config/openapi.yaml
This is not yet much used; feedback is welcome.

## Commodity styles

Expand Down

0 comments on commit 121b648

Please sign in to comment.