Simon Michael
1011029356
imp: pager set extra LESS options for a nice experience when using less
...
Currently this sets a rather ambitious set of options,
and overrides the existing LESS:
--chop-long-lines
--hilite-unread
--ignore-case
--mouse
--no-init
--QUIT-AT-EOF
--quit-if-one-screen
--RAW-CONTROL-CHARS
--squeeze-blank-lines
--use-backslash
--use-color
2024-10-31 19:13:39 -10:00
Simon Michael
30086ae249
imp: run pager more robustly; drop pager lib [ #2272 ]
...
This fixes the error displayed when quitting the pager with long output.
It also replaces the pager lib with more robust homegrown pager utilities,
which should prevent a number of failure modes.
2024-10-31 18:55:09 -10:00
Simon Michael
50bf401ea6
dev: split debug/ghcdebug flags, comment out the latter for now
...
Compilation with ghc-debug is failing, and it has not yet been used
for anything. Separate the flag and leave it in place but commented for now.
2024-10-24 10:44:28 -10:00
Simon Michael
2d90550e25
dev: cleanups
2024-10-20 09:13:58 -10:00
Simon Michael
f8cc9cdb4d
;dev: document runPager's behaviour precisely
2024-10-20 08:10:07 -10:00
Simon Michael
7325b75d5b
imp: rename ghcdebug build flag to debug, and enable stack traces with it
...
Builds made with ghc 9.10+ and the 'debug' build flag, will show
(some kind of, partial) stack traces when the program ends with an
error. (And also will have ghc-debug support enabled.)
The stack traces will probably improve in due course.
2024-10-19 18:47:03 -10:00
Simon Michael
f5b10b2d40
dev: cleanups
2024-10-19 16:56:14 -10:00
Simon Michael
b940254025
imp:cli: detect --color more safely in most cases
...
--color now also works in a config file, like --pager, except for two
cases: it does not affect colouring of debug output, or the colouring
helpers used in the check recentassertions error message.
2024-10-19 16:28:36 -10:00
Simon Michael
711d921774
imp:cli: --no-pager -> --pager, make this and --color safe options
2024-10-19 16:28:36 -10:00
Simon Michael
3e48451c3f
imp: note unsafe args / config file limitation; make --no-pager safe
2024-10-19 16:28:36 -10:00
Simon Michael
ba786752d1
imp 📟 add a --no-pager general flag
2024-10-19 16:28:36 -10:00
Simon Michael
db748465a8
fix 📟 when the $PAGER is not in PATH, print instead of failing
2024-10-19 16:28:36 -10:00
Simon Michael
4441680d7b
fix:lib:Hledger.Utils.IO.pager: avoid a crash; avoid an extra newline
2024-10-19 16:28:36 -10:00
Simon Michael
3b7420b97c
feat: use a pager for all large terminal output, not just for help
2024-10-19 16:28:36 -10:00
Simon Michael
c92b601028
dev: fix warnings with ghc 9.10 / base 4.20
...
Older ghc versions should also still build cleanly (tested with 9.8 so far).
I don't like enabling CPP in so many modules but it's easier that
figuring out how to do it with base-compat; hopefully no noticeable
compilation impact.
2024-09-30 17:20:13 -10:00
Simon Michael
d19b353bfb
imp: improve bad regexp error message
...
Eg '(?:foo)' is not malformed, it's just not supported.
https://hledger.org/hledger.html#hledgers-regular-expressions
2024-07-24 11:06:13 +01:00
Simon Michael
6b24c09a58
feat: config file: ignore unsupported general options; refactor
2024-06-25 18:37:54 +01:00
Simon Michael
e1991be46f
feat: config file: add a real parser, support command-specific options
2024-06-25 18:37:54 +01:00
Simon Michael
f5c2ec681c
dev: refactor: merge Text.Megaparsec.Custom into Hledger.Utils.Parse
2024-06-25 18:37:54 +01:00
Simon Michael
49c4ccd0b7
dev: Hledger.Utils.IO: fix hlint warnings
2024-06-25 07:45:27 +01:00
Simon Michael
1fe7e7af8c
imp: cli: --color now also accepts y or n, like --pretty
2024-05-29 09:37:20 -10:00
Simon Michael
96caa8f352
fix: detect ghc-debug support more accurately, checking hledger-lib also
2024-05-01 15:27:42 -10:00
Simon Michael
d17b32c7eb
imp: cli,ui,web: support ghc-debug for analysing memory/profile info
...
When built with the ghcdebug flag and started with --debug=-1 (or -2
to pause at startup, or -3 to pause before exit), hledger can be
controlled by ghc-debug clients like ghc-debug-brick or a custom
ghc-debug query script.
Also, refactor version string code.
2024-05-01 13:43:04 -10:00
Simon Michael
8f1ae401f4
dev: fix some partial head/tails, silence ghc 9.8's new warnings
...
Note the headErr/tailErr calls will print stack traces if they fail
(small ones: five lines, one of which is the useful location info),
which may or may not be best UX.
2024-02-28 15:58:21 -10:00
Simon Michael
e6b3fa0f54
dev:IO: comments
2024-02-22 07:32:10 -10:00
Simon Michael
8f6b7b202e
fix: traceOrLog and a rare warning from valuation code
...
Hledger.Utils.Debug.traceOrLog was logging when it should trace and vice versa.
This affected a warning which Hledger.Data.Valuation.pricesShortestPath
should display if encountering a pathologically long (>1000) price chain.
Also note some oddities about that warning.
2023-12-23 19:22:33 -10:00
Simon Michael
42c7383f57
;dev:Hledger.Utils.Parse: cleanup
2023-12-23 19:22:33 -10:00
Simon Michael
4b7e7f77bd
;dev:Hledger.Utils.Debug: haddockify some comments so they show in hover
2023-12-23 19:22:33 -10:00
Simon Michael
d1635a55f8
lib: move readFileStrictly to Hledger.Utils.IO
2023-12-07 03:41:31 -10:00
Simon Michael
7899b992b7
fix: prevent a Glob/filemanip package conflict in IO.hs
2023-12-05 17:43:04 -10:00
Simon Michael
96f9c1d2b2
;dev: lotcostp: cleanup
2023-11-23 09:14:54 -10:00
Simon Michael
4b13af0634
imp:print:beancount: conversion improvements
...
- omit balance assertions
- replace more currency symbols, and match within symbols like C$
- do more account validation, and error if conversion is too hard
- backslash-escape double quotes and backslashes in payee and note
2023-11-23 01:47:15 -10:00
Simon Michael
e2cc2d7e24
feat:print: add a basic beancount output format
...
This prints journal output more likely (but not guaranteed) to
be readable by Beancount.
All packages now require text 1.2.4.1 or greater.
2023-11-22 22:57:36 -10:00
Simon Michael
d435557979
lib: Hledger.Utils.Debug: lbl_ helper, cleanups, notes
2023-11-08 13:50:33 -08:00
Jonathan Dowland
549c47bca8
;dev: add Utils.Regex.regexMatchTextGroups
...
A matcher function which returns the list of match-groups, which may
be empty.
Signed-off-by: Jonathan Dowland <jon@dow.land>
2023-11-08 13:49:39 -08:00
Simon Michael
ddae3af8a3
lib: Hledger.Utils.IO: added expandGlob, sortByModTime
2023-05-19 09:09:21 -10:00
Simon Michael
3d2ef21081
lib: Hledger.Utils.IO: more robust monochrome pretty/debug printing
2023-05-18 07:19:36 -10:00
Simon Michael
83de76b67a
lib: Hledger.Utils.IO: avoid excessively wide "compact" prettyprinting
2023-05-18 07:19:36 -10:00
Simon Michael
1de8600067
imp: cli: try to ensure less (and its more mode) show ANSI ( fix #2015 )
...
If you use some other $PAGER, you will have to configure it to show
ANSI yourself (or disable ANSI, eg by setting NO_COLOR=1).
2023-04-06 11:13:00 -10:00
Simon Michael
c661fa7763
dev: lib: refactor pager
2023-04-06 11:12:56 -10:00
Simon Michael
c2ab616c2d
dev: unbreak recent change, don't re-export Color/ColorIntensity for now
2023-03-18 20:19:50 -10:00
Simon Michael
be8e64e498
imp: lib: export more terminal size, ANSI style/color helpers
...
Hledger.Utils.IO (and therefore Hledger and Hledger.Cli.Script) added:
getTerminalHeightWidth
getTerminalHeight
getTerminalWidth
Color(..)
ColorIntensity(..)
bold'
faint'
black'
red'
green'
yellow'
blue'
magenta'
cyan'
white'
brightBlack'
brightRed'
brightGreen'
brightYellow'
brightBlue'
brightMagenta'
brightCyan'
brightWhite'
rgb'
2023-03-18 19:59:00 -10:00
Simon Michael
5ddb6028ed
;dev: lib: cleanup
2023-03-16 21:52:37 -10:00
Simon Michael
ee29893040
dev: fix Hledger.Utils.String import
2023-03-16 14:48:59 -10:00
Simon Michael
d3e4f8547c
imp: lib: Hledger.Utils.String: more string strippers
...
added:
strip1Char
stripBy
strip1By
Not used in hledger right now, but useful to offer in our scripting prelude.
2023-03-16 14:35:37 -10:00
Simon Michael
c790aa6145
;dev: lib: also build with GHC 9.6.1; add base-compat
2023-03-14 10:42:48 -10:00
Simon Michael
6dc91588e4
fix: lib: avoid using pager on Windows, part 2
2023-03-10 20:58:11 -10:00
Simon Michael
41e838ef83
fix: lib: avoid using pager on Windows, the package is not supported
2023-03-10 19:14:13 -10:00
Simon Michael
9381b46004
fix: lib: fix terminal lightness detection
2023-01-27 16:51:05 -10:00
Simon Michael
79914cbe74
fix: cli: avoid showing color detection escape sequence when piped
2023-01-27 10:50:56 -10:00
Simon Michael
110711a2a2
fix: cli: restore workaround to avoid showing escape codes in emacs
2023-01-27 10:00:07 -10:00
Simon Michael
eed8a06906
fix: cli: don't highlight help when TERM=dumb
2023-01-27 06:06:17 -10:00
Simon Michael
bb5d473955
fix: lib: don't use $PAGER when TERM=dumb
2023-01-27 06:01:49 -10:00
Simon Michael
45808c8e13
imp: cli: add terminalLightness; tweak IsLight threshold; embolden banner
2023-01-26 22:11:20 -10:00
Simon Michael
1da4fd1eaf
imp: lib: terminal colour detection
...
added:
terminalIsLight
terminalFgColor
terminalBgColor
2023-01-26 22:11:20 -10:00
Simon Michael
d77d76e17f
imp: cli: use $PAGER when help output is taller than terminal
...
This works with hledger, hledger -h and hledger CMD -h.
2023-01-25 17:20:27 -10:00
Chris Lemaire
4ada2a3fbc
journal: Fully unbracket AccountNames in account directives
...
Currently an account name like "a:(aa)" will not have (aa) unbracketed.
However, this seems reasonable since the full name is unbracketed and
thus will not be confused with virtual or virtual-balanced posting.
2023-01-23 12:43:13 -10:00
Simon Michael
e891eecb8b
dev: add TypeOperators pragma to satisfy ghc 9.4
2023-01-10 19:33:31 -10:00
Simon Michael
fa8f6ae302
lib: Debug: breakpoint doesn't support windows yet, drop for now
2022-12-01 12:20:29 -08:00
Simon Michael
6d2687e67d
fix: debug logging: fix non-logging ptrace*IO, dbg*IO
2022-11-07 14:50:13 -10:00
Simon Michael
b0966adc93
dev: debug logging: ".log" suffix instead of ",logging"; improve docs
2022-11-06 09:01:12 -10:00
Simon Michael
b079bbdb4e
dev: lib: Hledger.Utils cleanup
2022-11-04 22:19:24 -10:00
Simon Michael
79047ccc43
dev: lib: consolidate some utils in Hledger.Utils.IO
2022-11-04 19:14:36 -10:00
Simon Michael
fc8aa5253a
dev: lib: Hledger.Utils.Print -> Hledger.Utils.IO
2022-11-04 18:39:31 -10:00
Simon Michael
80249c3e8a
dev: lib: Utils cleanups
2022-11-04 09:51:25 -10:00
Simon Michael
5bc977442a
dev: lib: remove NOINLINE pragmas HLS doesn't complain about
2022-11-03 17:58:32 -10:00
Simon Michael
0608a76243
dev: lib: extract progArgs, minimise unsafe IO
...
It is exported from the increasingly-inaccurately-named
Hledger.Utils.Print for now.
2022-11-03 17:58:13 -10:00
Simon Michael
988c164ec8
imp: debug logging improvements; hledger-ui logs to hledger-ui.log only
...
Hledger.Utils.Debug's "trace or log" functions are now controlled as
follows: to enable logging, append ",logging" to the program name at
startup (using withProgName). This also works when running in GHCI.
And they log to PROGNAME.log, not debug.log.
All (hopefully) debug logging in the hledger packages is now "trace or
log" capable.
This means that hledger-ui should now log all debug output to
./hledger-ui.log, with none of it appearing on the console.
2022-11-03 16:07:54 -10:00
Simon Michael
603fae70c0
dev: lib: clean up/simplify debug helpers
2022-10-31 11:26:11 -10:00
Simon Michael
ddb3ea777e
imp: lib: move hledger-specific things out of Hledger.Utils.Debug
...
Moved from Hledger.Utils.Debug to Hledger.Utils.Parse:
traceParse
traceParseAt
dbgparse
2022-10-29 13:04:47 -10:00
Simon Michael
fd82fa48c9
imp: lib: separate Hledger.Utils.Print
...
Moved from Hledger.Utils.Debug to Hledger.Utils.Print:
pshow
pshow'
pprint
pprint'
colorOption
useColorOnStdout
useColorOnStderr
outputFileOption
hasOutputFile
2022-10-29 12:39:46 -10:00
Simon Michael
82a503cbf5
imp: lib: Hledger.Utils.Parse: export customErrorBundlePretty
...
for pretty-printing hledger parse errors.
2022-10-07 06:34:34 -10:00
Simon Michael
5c14ed2ec9
dev: lib: clarify dlogAt's doc
2022-09-10 12:44:21 -10:00
Simon Michael
c80c72d7cd
dev: lib, cli, bin: enable/fix name shadowing warnings
...
And a few other cleanups.
2022-08-23 12:16:15 +01:00
Simon Michael
9584ebb439
imp: lib: Hledger.Utils.Debug: re-export Debug.Breakpoint
...
And add breakpoint as a dependency and enable its GHC plugin in all
the hledger packages, so that breakpoint's helpers can be used easily.
2022-08-23 02:02:19 +01:00
Simon Michael
b7b09f991a
imp: lib: Hledger.Utils.Debug: fix debug logging to file
...
dlog has been replaced by more reliable functions for debug-logging
to a file, useful for debugging TUI apps like hledger-ui:
dlogTrace
dlogTraceAt
dlogAt
dlog0
dlog1
dlog2
dlog3
dlog4
dlog5
dlog6
dlog7
dlog8
dlog9
Monochrome pprint' and pshow' have been added.
New dependency: deepseq
2022-08-23 00:50:51 +01:00
Simon Michael
101e2f7426
imp: add a missing space after colon in some debug output
2022-08-16 09:13:30 +01:00
Simon Michael
442ef9361c
feat: api: quoteForCommandLine: some very shady CLI escaping
2022-07-31 08:26:30 +01:00
Simon Michael
1c67d0860e
imp: errors: more error prettification
2022-07-13 03:59:44 +01:00
Simon Michael
dd14f9c822
imp: lib: Hledger.Utils.Parse: export HledgerParseErrors
2022-06-29 09:58:56 +01:00
Simon Michael
5ab7b9f643
ref: HledgerParseErrors type alias
2022-04-25 02:56:59 -10:00
Simon Michael
2f28e1b0a7
ref: rename CustomErr -> HledgerParseErrorData
...
Verbose, but use every chance to clarify the complicated parse error
situation.
2022-04-25 02:56:59 -10:00
Stephen Morgan
1aff74f702
cln: Reduce duplication in test utilities.
2022-03-26 15:35:19 -10:00
Stephen Morgan
19ed6d3f00
cln!: sourcepos: Use megaparsec-supplied sourcePosPretty.
...
Change showSourcePos to sourcePosPretty, and showSourcePosPair to
sourcePosPairPretty.
2022-03-10 16:56:28 -10:00
Stephen Morgan
e9dd77e82b
fix: Ensure head and tail are not called on empty account names.
2021-12-22 14:37:37 -10:00
Simon Michael
35c1c9b6a2
pkg: progress towards supporting GHC 9.2 and newer libs ( #1774 )
...
hledger-lib builds, hledger's deps don't (shakespeare).
2021-12-06 12:32:50 -10:00
Simon Michael
3c889cb565
imp: lib: dlog
2021-11-20 07:49:41 -10:00
Stephen Morgan
ff0132df28
dev: Use realLength from doclayout instead of strWidth and textWidth. ( #895 )
...
This gives us more accurate string length calculations. In particular,
it handles emoji and other scripts properly.
2021-11-11 18:29:50 -10:00
Stephen Morgan
afdeb404b0
fix: colour: NO_COLOR flag no longer overrides an explicit --color option. ( #1710 )
...
http://no-color.org/ specifies that command line arguments should
override a NO_COLOR flag.
2021-09-21 15:32:53 -10:00
Stephen Morgan
4cfd3cb590
lib!: Remove GenericSourcePos, and replace it with either SourcePos or
...
(SourcePos, SourcePos).
This has been marked for possible removal for a while. We are keeping
strictly more information. Possible edge cases arise with Timeclock and
CsvReader, but I think these are covered.
The particular motivation for getting rid of this is that
GenericSourcePos is creating some awkward import considerations for
little gain. Removing this enables some flattening of the module
dependency tree.
2021-09-20 08:38:33 -10:00
Stephen Morgan
df71d2ddd5
dev: Move journal and text parsing utilities into more appropriate places, to reduce reliance on Hledger.Read.Common.
2021-09-19 17:10:38 -10:00
Stephen Morgan
c1d85ba17c
ref: Move JournalParser and ErroringJournalParser to Hledger.Data.Journal.
...
This is so that Hledger.Utils does not depend on Hledger.Data in any
way, and allows us more flexibility in refactoring Hledger.Data.
2021-09-18 11:41:53 -10:00
Stephen Morgan
8274da81fc
cln: tests: Remove test and tests, which are just aliases for testCase
...
and testGroup.
Replacing these removes a layer of indirection, and reduces the need to
depend on Hledger.Utils.Test.
2021-08-30 16:32:19 -10:00
Stephen Morgan
a0f9d7560f
pkg!: Remove Hledger.Utils.Color module.
...
This module was only used in one place in Hledger.Data.Amount. The code
has been moved directly into Hledger.Utils.
2021-08-30 15:57:33 -10:00
Stephen Morgan
f1994d5aa8
pkg!: Remove Hledger.Utils.Tree module.
...
This very small module was only used in Hledger.Data.Account, so the
code was moved into that module instead.
2021-08-30 15:57:33 -10:00
Stephen Morgan
1ed06f3bc8
pkg!: Remove Hledger.Utils.UTF8IOCompat module.
...
This module does nothing beyond define error' and usageError, which have
been moved to Hledger.Utils.
2021-08-30 15:57:33 -10:00
Stephen Morgan
d248aec313
cln: hlint: Remove eta reduce warnings.
2021-08-27 06:13:56 -10:00
Stephen Morgan
8bf7c95697
cln: hlint: Clean up Functor related hlint warnings, and NOINLINE warning.
2021-08-27 06:13:56 -10:00
Stephen Morgan
beecb3c9ac
cln: hlint: Clean up list related hlint warnings.
2021-08-27 06:13:56 -10:00
Stephen Morgan
22db5c4a3f
cln: hlint: Remove warnings to use library list functions.
2021-08-27 06:13:56 -10:00