Commit Graph

2590 Commits

Author SHA1 Message Date
Simon Michael
2a4718d40a fix: make a few more error messages consistent, hiding call stack [#2367] 2025-06-03 10:10:04 -10:00
Michael Rees
0c3e7bc395 Always check added transaction, even if no immediate assertion 2025-05-31 23:19:47 -10:00
Michael Rees
b042115692 Ignore assertions during add with -I 2025-05-31 23:19:47 -10:00
Michael Rees
5a4aa87df8 Clarify some code after review 2025-05-31 23:19:47 -10:00
Michael Rees
17f914e571 imp: add: Verify balance assertions on each posting (#2355) 2025-05-31 23:19:47 -10:00
Simon Michael
713773cfc3 imp: simplify the unicode decode error message; refactor 2025-05-30 09:43:30 -10:00
Simon Michael
4587eccdf4 ;fix: recognise another case of text decoding failure 2025-05-29 12:25:06 -10:00
Simon Michael
e360e50497 imp:csv: more --debug=2 output for if rules
Also, in debug output show records more like what matchers are seeing,
ie with quotes removed.
2025-05-22 17:05:45 -10:00
Simon Michael
9474d808dc ;imp:lib:Hledger.Utils.Debug: more cleanups, docs
This and/or the previous related change also changed a few cases which
always traced or always logged; now all debug output is consistently
either traced or logged.
2025-05-22 17:03:50 -10:00
Simon Michael
0d014577c2 ;imp:lib:Hledger.Utils.Debug: more cleanup 2025-05-21 23:07:14 -10:00
Simon Michael
820a44eb07 imp:lib:Hledger.Utils.Debug: simpler, more consistent dbg* names 2025-05-21 22:54:00 -10:00
Simon Michael
297cf30e60 ;dev: journalValueAndFilterPostingsWith notes [#2371], [#2385] 2025-05-17 02:09:27 -10:00
Stephen Morgan
447a681645 fix: Ensure valuation happens after filtration (#2385) 2025-05-17 00:00:33 -10:00
Simon Michael
8f6a7c8a66 fix: web: don't hang when saving a large file [#2319] 2025-05-16 09:44:26 -10:00
Simon Michael
151b36a6f2 ;dev: haddock edits 2025-05-16 09:42:55 -10:00
Stephen Morgan
eda4c8dd62 dev: lib: Add NFData instances for Journal and subcomponents. 2025-05-02 08:30:38 -10:00
Stephen Morgan
468a3da1b7 dev: lib: Use strict data in Hledger.Data.Types.
This reduces memory usage and results in speedups in some commands.
2025-05-02 08:30:17 -10:00
Simon Michael
330f3fccaa ;dev: rename assertions.test 2025-04-27 08:30:18 -10:00
Simon Michael
2371f677e5 imp:journal: include directive now allows a same-line comment 2025-04-27 08:30:18 -10:00
samahri
4f9473240f cli: "balanced" check is enabled only with "check" command 2025-04-26 20:05:00 -10:00
Simon Michael
bca4b39c58 lib: defaultJournalSafely: don't strip newline 2025-04-25 15:42:47 -10:00
Simon Michael
f0f048326e lib: defaultJournalSafely wasn't very safe; now catches error calls 2025-04-25 15:21:11 -10:00
Simon Michael
bf40d28c8b imp: config files (and maybe timedot files) no longer require a final newline 2025-04-25 13:59:18 -10:00
Simon Michael
b0959cb23d lib:Hledger.Utils.IO: document some file reading utilities 2025-04-25 09:21:11 -10:00
Simon Michael
45d5fd7963 imp: show a clearer error message on unicode en/decoding failures [#73]
A very long-awaited improvement: for unicode exceptions, and I/O
exceptions which look like they were caused by a unicode error
(usually text decoding failure), our error message now includes
an explanation and advice on what to do.

Currently this uses the GHC.IO.Encoding API, which is not ideal:
"The API of this module is unstable and not meant to be consumed by
the general public. If you absolutely must depend on it, make sure to
use a tight upper bound, e.g., base < 4.X rather than base < 5,
because the interface can change rapidly without much warning."

Also it relies on scanning for patterns in GHC's various
unicode-related error messages, which may not be complete and could
change in future. To do: try the encoding package's IO helpers,
perhaps they give more specific exceptions.
2025-04-25 08:57:07 -10:00
Simon Michael
06cd0f9472 lib: exitOnExceptions -> exitOnError 2025-04-25 08:32:47 -10:00
Simon Michael
fea127fcb5 ;doc: note check-related bug in rawOptsToInputOpts [#2377] 2025-04-24 10:44:34 -10:00
Simon Michael
036be45c50 lib: make parseYN(A) total; export findPager 2025-04-23 21:43:30 -10:00
Simon Michael
4788bd9e41 lib: journalCommoditiesUsed 2025-04-23 21:43:30 -10:00
Simon Michael
255e79c550 lib: Hledger.Read: more ways to read the default journal
defaultJournalWith, defaultJournalSafely, defaultJournalSafelyWith
2025-04-22 18:50:42 -10:00
Simon Michael
a13b7d2a82 lib: Hledger.Data.Dates.parsedate: also accept YYYYMMDD format; document
- Added support for unseparated dates, for convenience in ghci and for parseHledgerVersion
- Noted two user-facing uses: --value's argument, and import's .latest files.
  YYYYMMDD dates will now also work there. Left this undocumented.
- Noted this is now more permissive, parsing many integers successfully; not expecting problems.
2025-04-22 16:59:57 -10:00
Simon Michael
98b40b2b0e ;dev: fix a warning 2025-04-22 12:26:55 -10:00
Simon Michael
b7509030c5 lib: Hledger.Data.Dates: parsedateM -> parsedate
M makes me think of monad and is awkward to type for this common helper; Maybe is expected for a parser.
2025-04-22 10:40:41 -10:00
Simon Michael
f37a4a7dcb lib: refactor, export getHomeSafe 2025-04-20 10:52:50 -10:00
Simon Michael
81238e5f27 feat: any:, all: queries allow more powerful transaction matching 2025-04-18 14:06:45 -10:00
Simon Michael
9340b73aae imp: improve/format errors for various failures [#2367]
These now call error' and show errors in the standard style:

- reading a nonexistent data file
- reading an unsafe dotted file name on windows
- web: using --socket on windows
- demo: demo not found
- demo: error while running asciinema
- diff: bad arguments
- print --match: no match found
- register --match: no match found
- roi: no investment transactions found
2025-04-11 08:06:47 -10:00
Simon Michael
454c669fe4 fix:cli,ui,web: consistent console error output independent of GHC version [#2367]
Hledger.Utils.IO helpers have been updated and new ones have been
added (exitOnExceptions, exitWithError) to allow consistent display of
program errors whether compiled with GHC <9.10, GHC 9.10, or GHC >9.10.
The trailing newlines added by GHC 9.10 are gone,
and so is the "uncaught exception" output added by GHC 9.12.
2025-04-11 08:06:47 -10:00
Michael Rees
62071bc4c2 feat: timeclock: Add support for multiple clocked in sessions (#2141)
We now support having multiple sessions clocked in. These are paired by
account name if given on the out entry, and otherwise an out closes the
most recent in entry.

Note that this breaks some backwards compatibility, in that we
previously ignored the description on the clock out entry. To mitigate
this, a new hidden flag --timeclock-old has been added, which reverts to
the old behavior.
2025-04-03 11:19:18 -10:00
Thomas Miedema
e7cc2f1066 ;dev: lib: drop base-compat dependency 2025-03-31 16:21:38 -10:00
Thomas Miedema
4d5ff3fe4e ;dev: make doctest happy on ghc-8.10.7 2025-03-31 16:18:09 -10:00
Simon Michael
133560aa93 ;dev: csv: no need to test for unsupported feature [#2352] 2025-03-12 20:40:36 -10:00
Thomas Miedema
a8a0d3ee30 fix: csv: fix regression in parsing rules containing & (#2352) 2025-03-12 20:35:59 -10:00
Dmitry Astapov
1fc7006919 run: cache input files by (iopts, name), allows commands with different iopts 2025-03-06 11:54:00 -10:00
Simon Michael
d47107ab7a ;dev:readJournal: doc 2025-03-06 05:39:23 -10:00
Simon Michael
874771d47c dev:readJournal: assume default file name "-" rather than "(string)" [#2328]
"-" implies data from standard input so "string" is perhaps more
correct, but I think this is a harmless simplification and it
makes `files` output consistent when run by `run`.
2025-03-06 05:13:37 -10:00
Simon Michael
cb373447db fix:cli:paging: support older less, don't pass --use-color [#2335]
Older less versions (eg 551) require --use-colour, and break if --use-color is passed. So we no longer attempt to enable colour in less by default.
2025-03-04 16:38:25 -10:00
Thomas Miedema
2faceb8e1b feat: csv: allow multiple matchers on the same line
`If blocks` and `If tables` now allow multiple matchers on the same line
separated by `&&` (AND) or `&& !` (AND NOT).

Example `if block` with two matchers on the same line:

	if %description amazon && %date 2025-02-22
	    account2 expenses:books

Example `if table` with two matchers on the same line:

	if,account2
	%description amazon && %date 2025-02-22, expenses:books
2025-03-01 11:21:00 -10:00
Simon Michael
d346e56b79 dev: fix warnings, update yaml file, edit [#2340] 2025-02-27 13:41:48 -10:00
gesh
a24c39f13f fix: Use POSIX API to compute tty width (#2332)
On some systems, TERM is set to a value that doesn't have a valid
terminfo entry. Rather than hackily fall back on a value for TERM that
appears to work in most contexts (TERM=dumb) but which isn't guaranteed
anywhere to be valid, use proper POSIX ioctls to get the tty width.

This has the added bonus of also working on Windows.

In fact, we already settled on computing the terminal size in this way
in hledger-lib, so this commit centralizes the choice of the logic
there.

Also added a note for alternative methods and their tradeoffs, in case
this turns out to be fragile on some systems.
2025-02-27 13:41:48 -10:00
Joschua Kesper
5114962b2a feat:csv: add an encoding rule, allowing non-UTF8 CSV to be read [#2319]
Previously, hledger could read CSV files containing non-ascii
characters only if they are UTF8-encoded.  Now there is a new CSV
rule, encoding ENCODING, which allows reading CSV files with other
encodings.

This adds a dependency on the encoding library, which supports fewer
encodings than text-icu but does not require a third-party C library.
To avoid build issues on various platforms, we require version 0.10+.

This adds some use of the ImplicitParams language extension, required
by encoding's API, but only in a small code region.

This also changes the type of Reader's rReadFn; it now takes
a `Handle` rather than a `Text`, allowing more flexibility.
2025-02-15 14:48:30 -10:00