Commit Graph

129 Commits

Author SHA1 Message Date
Stephen Morgan
371b349b2e lib,cli: Replace parsedate and mkdatespan with direct applications of fromGregorian, transaction now takes Day instead of a date string. 2020-08-29 15:08:28 -07:00
Simon Michael
3f55c23603 ;review, tag all error calls with an easier to find PARTIAL: comment (#1312) 2020-08-05 16:08:33 -07:00
Simon Michael
765fb732c9 debug: move command parsing debug output down to level 8 2020-07-03 11:37:01 -07:00
Simon Michael
684cb45e1a tweak debug levels, document some guidelines
Beginnings of a project-wide policy for what output to show at
each debug level, for now. Later we'll want more flexibility,
eg filtering by topic.
2020-06-14 17:17:09 -07:00
Simon Michael
9868d7f20d ;lib: update emacs code-folding config
orgstruct-mode was dropped from org 9.2, and I shouldn't have been
forcing it on anyway.

The new config allows its "replacement", outshine-mode, to do similar
code folding when you press tab on any of the lines matching
outline-regexp. But only if you patch it as mentioned at
https://github.com/alphapapa/outshine/issues/77.
Enable it by, eg: (add-hook 'haskell-mode-hook 'outshine-mode)
2020-03-28 17:09:47 -07:00
Stephen Morgan
e0dde6fe57 lib: Remove non-law-abiding Monoid instance for Journal. 2020-03-02 12:45:30 -08:00
Stephen Morgan
702c958487 lib: Replace some utility functions with library functions. 2020-03-02 12:45:30 -08:00
Simon Michael
374be00223 ;lib: fix org headings and doctest setup that were breaking haddock
(and in some cases, installation).
[ci skip]
2020-03-01 22:00:39 -08:00
Simon Michael
b9954bff60 journal, lib: the include directive no longer guesses the format
The include directive now tries just one reader, based on the file
extension and defaulting to journal, like the rest of hledger.
(It doesn't yet handle a reader prefix.)

Reader-finding utilities have moved from Hledger.Read to
Hledger.Read.JournalReader so the include directive can use them.

Reader changes:
- rExperimental flag removed
- old rParser renamed to rReadFn
- new rParser field provides the actual parser.
  This seems to require making Reader a higher-kinded type, unfortunately.
2020-03-01 14:06:29 -08:00
Simon Michael
b1f3880c3d lib: drop the file format auto-detection feature
For a long time hledger has auto-detected the file format when it's
not known, eg when reading from a file with unusual extension (like
.dat or .txt), or from standard input (-f-), or when using the include
directive (which currently ignores file extensions).

Auto-detecting has been done by trying all readers until one succeeds.
This could guess wrong in some cases, but it was so rare that it has
been working fine.

Recently, more conveniences have been added to timedot format,
increasing its overlap with journal format, which makes this kind of
auto-detection unreliable.

Auto-detection and auto-detection failures are (probably) still pretty
rare in practice. But when it does happen it's confusing, giving
misleading errors or false successes (eg printing timedot entries
instead of a journal error).

For predictability and to minimise confusion, hledger no longer tries
to guess; when there's no file extension or reader prefix, it assumes
journal format. To specify one of the other formats, you must use a
standard file extension (.timeclock, .timedot, .csv, .ssv, .tsv), or a
reader prefix (-f csv:foo.txt, -f timedot:-).

For now, the include directive still tries to autodetect
(journal/timeclock/timedot), and this can't be overridden; it will be
fixed later.

Experimental; testing and feedback welcome.
2020-03-01 14:06:29 -08:00
Simon Michael
8ad2ea2fb4 lib: Hledger.Read cleanup 2020-02-27 23:51:54 -08:00
Simon Michael
7ec25da13a web: edit/upload: normalise line endings, avoiding parse errors (#1194)
Renamed: writeValidJournal -> writeJournalTextIfValidAndChanged

Added comments clarifying line ending behaviour of:
add, import, appendToJournalFileOrStdout, readFilePortably,
writeFileWithBackupIfChanged, writeJournalTextIfValidAndChanged

Summary of current behaviour:

- hledger add and import commands will append with (at least some)
  unix line endings, possibly causing the file to have mixed line
  endings

- hledger-web edit and upload forms will write the file with
  the current system's native line endings, ie changing all
  line endings if the file previously used foreign line endings.
2020-02-24 14:04:44 -08:00
Simon Michael
62a9e1aa62 ;lib: clarify Hledger.Read imports a little 2019-12-02 08:21:06 -08:00
Simon Michael
180f4baedb ;lib: csv: note cause of #1087
[ci skip]
2019-09-14 03:45:37 -07:00
Simon Michael
6e3a264f17 lib: export aliasnamep for hledger-check (#1072) 2019-07-16 23:30:15 +01:00
Caleb Maclennan
11d9e5eb6a code: Strip extraneous trailing whitespace from Haskell sources 2019-07-15 16:40:49 +01:00
Simon Michael
014db152d9 add, web: disallow unsafe trailing dot paths on windows (fix #1056)
On Windows, ensureJournalFileExists now rejects file paths
containing any problematic trailing dots, to prevent data loss.
This affects the add command and hledger-web's add form.
2019-06-26 18:19:53 +01:00
Simon Michael
944554557a tweak readJournalFiles type signature 2019-01-15 06:18:56 -08:00
Simon Michael
91b111b60d rename easytests_* to tests_* 2018-09-06 13:13:26 -07:00
Simon Michael
f3709f241d tests: port Read tests to easytest 2018-09-03 15:42:24 -07:00
Simon Michael
d1cff46ba7 tests: port CsvReader tests to easytest 2018-09-03 15:30:52 -07:00
Simon Michael
cd67f8ea68 tests: clear out old boilerplate 2018-08-31 18:12:17 -07:00
Simon Michael
d1a7cc1c09 port remaining Read.Common tests 2018-08-31 18:12:17 -07:00
Simon Michael
f108b56e61 uniquify modules' easytests, simplify imports 2018-08-20 14:31:31 +01:00
Simon Michael
6568784bf6 port remaining JournalReader tests 2018-08-20 14:31:31 +01:00
Simon Michael
d778a92561 tests: export HUnit/EasyTest from Hledger.Utils.Test; more helpers 2018-08-18 15:19:59 +01:00
Simon Michael
b4c336c874 test/_test/it/_it helpers; refactor easytests
This makes skipping/unskipping tests easier, and improves readability
a bit.

Note it's also possible to just write the test name with no preceding
function, when the type is constrained (see Journal.hs).
2018-08-17 13:40:37 +01:00
Simon Michael
626247bacd journal: unit tests (2 skipped) for periodtransactionp (#823) 2018-08-17 12:42:43 +01:00
Simon Michael
50d666d5a0 test: refactor, document, organise easytests, port amountp tests (#812) 2018-08-15 19:58:07 +01:00
Jakub Zárybnický
c67404c73d lib: Fix compile errors in tests 2018-08-14 16:05:06 +01:00
Dmitry Astapov
d82370d10b lib, app, web: remove differences between command line and journal file aliases 2018-04-17 16:09:11 -07:00
Dmitry Astapov
f6ec26e321 lib, app, web, ui: rename readJournalFile[s]WithOpts to readJournalFile, same for tryReader[s]WithOpts 2018-04-17 15:25:02 -07:00
Simon Michael
ae8046d47b lib: restore/update haddocks on readJournalFile[s]WithOpts
[ci skip]
2018-04-17 14:34:43 -07:00
Dmitry Astapov
5579af9a04 lib: remove readJournalFile(s) - supeceded by readJournalFile(s)WithOpts 2018-04-17 14:33:32 -07:00
Dmitry Astapov
37607beaea lib, app, web: use readJournalFileWithOpts instead of readJournalFile whenever possible 2018-04-17 14:33:32 -07:00
Dmitry Astapov
ecf49b1e4b lib: auto postings generated before amount inference and balance checks (#729) 2018-04-17 14:33:32 -07:00
Simon Michael
81e964502b lib: refactor low-level text file reading 2018-01-04 16:17:25 -08:00
Simon Michael
5de51c9bad fix warnings/errors found by make stacktest 2017-09-30 13:00:22 -10:00
Simon Michael
7edacdf443 cli: import command! hledger import *.csv adds new txns to main file 2017-09-17 18:57:51 -07:00
Simon Michael
1edb828a75 lib, print: rename --new's save files to .latest.*, easier to manage 2017-09-17 13:26:42 -07:00
Simon Michael
669fa706c0 print: --new shows only transactions added since last time
First cut, error messages could be refined etc.
2017-09-15 09:55:17 -07:00
Simon Michael
e3c4a76119 add & use simpler readJournalFilesWithOpts/InputOpts api 2017-09-14 17:43:32 -07:00
Simon Michael
e8dcef5b5f lib: disable WIP ledger4 parser, lighten dependencies 2017-03-29 21:06:26 -07:00
Johannes Gerer
2e8e67aa09 Changed behavior of readJournalFiles to be identical to readJournalFile for singleton lists (#437) 2016-12-07 07:59:24 -08:00
Simon Michael
1f2276c100 lib: mark ledger reader as experimental, don't use automatically 2016-11-20 10:42:12 -08:00
Simon Michael
98ef8f9a60 lib, cli: allow a READER: prefix on data file paths
This provides a way to override the file format detection logic,
useful eg for files with wrong extensions or standard input.
2016-11-20 10:32:22 -08:00
Simon Michael
7d56af5a03 lib: restrict imports, avoiding GHCI clashes 2016-11-20 10:27:16 -08:00
Simon Michael
1539b258b9 lib: more Hledger.Read cleanup 2016-11-19 08:57:03 -08:00
Simon Michael
b6ff170688 lib: simplify format detection, avoid ledger reader by default
When we don't know a file's format, instead of choosing a subset of
readers based on content sniffing, now we just try them all.
Also, LedgerReader is now used only as a last resort,
as it's not yet competitive with JournalReader.
2016-11-18 13:24:57 -08:00
Simon Michael
12151e05c0 lib: some Hledger.Read cleanup 2016-11-17 20:20:07 -08:00