-
-
Notifications
You must be signed in to change notification settings - Fork 320
/
Justfile
1500 lines (1274 loc) · 61.3 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env just
# * Project scripts, using https://github.com/casey/just (last tested with 1.25)
# Usage: alias j=just, run j to list available scripts.
#
# After many years with make and plain shell and haskell for
# scripting, just is better enough, and the goal of clean consolidated
# efficient project automation is so valuable, that I am relying on it
# even though it's not installed by default.
#
# All of Makefile has been absorbed below; uncomment/update/drop
# remaining bits when needed. Makefile will be removed some time soon.
#
# just currently lacks make-style file dependency tracking. When that
# is needed for efficiency, or when more powerful code is needed, use
# Shake.hs instead of just.
#
#
# Lines beginning with "# * ", "# ** ", etc are section headings,
# foldable in Emacs outshine-mode. Here's some more highlighting you can add
# for readability:
# (add-hook 'just-mode-hook (lambda ()
# (display-line-numbers-mode 1)
# (highlight-lines-matching-regexp "^# \\*\\*? " 'hi-yellow) ; level 1-2 outshine headings
# (highlight-lines-matching-regexp "^@?\\w.*\\w:$" 'hi-pink) ; recipe headings (misses recipes with dependencies)
# ))
#
# This file is formatted by `just format`, which currently eats blank lines a bit.
# (It also commits.)
#
# 'set export' below makes constants and arguments available as $VAR as well as {{ VAR }}.
# $ makes just code more like shell code.
# {{ }} handles multi-word values better and is fully evaluated in -n/--dry-run output.
#
# Reference:
# https://docs.rs/regex/1.5.4/regex/#syntax Regexps
# https://just.systems/man/en/chapter_31.html Functions
# https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet
# https://github.com/casey/just/discussions
#
# Other tools used below include:
# - stack (http://haskell-lang.org/get-started, installs libs and runs ghc)
# - shelltestrunner (hackage, runs functional tests)
# - quickbench (hackage/stackage, runs benchmarks)
# - ghcid (hackage/stackage, recompiles and optionally runs tests on file change)
# - hasktags (hackage, generates tag files for code navigation)
# - profiterole (hackage/stackage, simplifies profiles)
# - profiteur (hackage/stackage, renders profiles as html)
# - dateround (from dateutils)
# ** Helpers ------------------------------------------------------------
HELPERS: help
set export := true
# and/or: -q --bell --stop-timeout=1
WATCHEXEC := 'watchexec --timings'
# grep-like rg
#RG_ := 'rg --sort=path --no-heading -i'
#TODAY := `date +%Y-%m-%d`
# just := "just -f " + justfile()
# Use this justfile from within its directory, otherwise we must write {{ just }} everywhere.
# list this justfile's recipes, optionally filtered by REGEX
@help *REGEX:
if [[ '{{ REGEX }}' =~ '' ]]; then just -ul; else just -ul | rg -i '{{ REGEX }}'; true; fi
alias h := help
# check this justfile for errors and non-standard format
@check:
just --fmt --unstable --check
# if this justfile is error free but in non-standard format, reformat it, and if it has changes, commit it
@format:
just -q chk || just -q --fmt --unstable && git diff --quiet || git commit -m ';just: format' -- {{ justfile() }}
# rerun RECIPE when any watched-by-default file changes
watch RECIPE *JOPTS:
#!/usr/bin/env bash
$WATCHEXEC -r --filter-file <(git ls-files) -- just $RECIPE {{ JOPTS }}
# rerun RECIPE when any git-committed file changes
watchgit RECIPE *JOPTS:
#!/usr/bin/env bash
$WATCHEXEC -r --filter-file <(git ls-files) -- just $RECIPE {{ JOPTS }}
# show watchexec env vars when any file changes, printing events and ignoring nothing
_watchdbg *WOPTS:
$WATCHEXEC --ignore-nothing --print-events {{ WOPTS }} -- 'env | rg "WATCHEXEC\w*"; true'
# show watchexec env vars when any git-committed file changes
_watchgitdbg *WOPTS:
#!/usr/bin/env bash
$WATCHEXEC -r --filter-file <(git ls-files) {{ WOPTS }} -- 'env | rg "WATCHEXEC\w*"; true'
# ** Constants ------------------------------------------------------------
BROWSE := 'open'
# XXX These often don't work well interpolated as $CMD or {{ CMD }}, not sure why
# find GNU tools, eg on mac
GDATE := `type -P gdate || echo date`
GTAR := `type -P gtar || echo tar`
#GNUTAR := `which gtar >/dev/null && echo gtar || echo tar`
# make ghc usable for scripting with -e
GHC := 'ghc -package-env - -ignore-dot-ghci -Wno-x-partial'
GHCI := 'ghci'
# GHCPKG := 'ghc-pkg'
# HADDOCK := 'haddock'
# CABAL := 'cabal'
# CABALINSTALL := 'cabal install -w {{ GHC }}'
# GHC-compiled executables require a locale (and not just C) or they
# will die on encountering non-ascii data. Set LANG to something if not already set.
# export LANG? := 'en_US.UTF-8'
# command to run during profiling (time and heap)
# command to run when profiling
PROFCMD := 'bin/hledgerprof balance -f examples/10000x1000x10.journal >/dev/null'
PROFRTSFLAGS := '-P'
# # command to run when checking test coverage
# COVCMD := 'test'
# COVCMD := '-f test-wf.csv print'
# Which stack command (and in particular, stack yaml/GHC version) to use for building etc. ?
STACK := 'stack'
#STACK := 'stack --stack-yaml=stack8.10.yaml'
# Or override temporarily with an env var:
# STACK := '"stack --stack-yaml=stack8.10.yaml" make functest'
# if using an unreleased stack with a newer hpack than the one mentioned in */*.cabal,
# it will give warnings. To silence these, put the old hpack-X.Y in $PATH and uncomment:
#STACK := 'stack --with-hpack=hpack-0.20'
# --threads := '16 sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" but seems harmless'
# --timeout := 'N is not much use here - can be defeated by multiple threads, unoptimised builds, '
# slow hackage index or compiler setup on first build, etc.
# Which stack command (stack yaml, GHC version) to use for ghci[d] operations ?
STACKGHCI := STACK
#STACKGHCI := 'stack --stack-yaml=stack9.2.yaml'
PACKAGES := '
hledger-lib
hledger
hledger-ui
hledger-web
'
# BINARIES := '
# hledger
# hledger-ui
# hledger-web
# '
INCLUDEPATHS := '
-ihledger-lib
-ihledger
-ihledger-ui
-ihledger-web
-ihledger-web/app
'
MAIN := 'hledger/app/hledger-cli.hs'
# All source files in the project (plus a few strays like Setup.hs & hlint.hs).
# Used eg for building tags. Doesn't reliably catch all source files.
SOURCEFILES := '
dev.hs
hledger/*hs
hledger/app/*hs
hledger/bench/*hs
hledger/test/*hs
hledger/Hledger/*hs
hledger/Hledger/*/*hs
hledger/Hledger/*/*/*hs
hledger-*/*hs
hledger-*/app/*hs
hledger-*/test/*hs
hledger-*/Hledger/*hs
hledger-*/Hledger/*/*hs
hledger-*/Hledger/*/*/*hs
hledger-lib/Text/*/*hs
'
HPACKFILES := '
hledger/*package.yaml
hledger-*/*package.yaml
'
CABALFILES := '
hledger/hledger.cabal
hledger-*/*.cabal
'
MANUALSOURCEFILES := '
doc/common.m4
*/*.m4.md
'
# MANUALGENFILES := '
# hledger*/hledger*.{1,5,info,txt}
# '
COMMANDHELPFILES := '
hledger/Hledger/Cli/Commands/*.md
'
WEBTEMPLATEFILES := '
hledger-web/templates/*
'
WEBCODEFILES := '
hledger-web/static/*.js
hledger-web/static/*.css
'
DOCSOURCEFILES := '
README.md
CONTRIBUTING.md
' + MANUALSOURCEFILES + COMMANDHELPFILES
TESTFILES := `fd '\.test$' --exclude ledger-compat`
# XXX it's fd-find on gnu/linux ?
# # file(s) which require recompilation for a build to have an up-to-date version string
# VERSIONSOURCEFILE := 'hledger/Hledger/Cli/Version.hs'
# Two or three-part version string, set as program version in builds made by this makefile.
# We use hledger CLI's current version (XXX for all packages, which isn't quite right).
export VERSION := `cat hledger/.version`
# Flags for ghc builds.
# Warnings to see during dev tasks like make ghci*. See also the warnings in package.yamls.
# XXX redundant with package.yamls ?
WARNINGS := '
-Wall
-Wno-incomplete-uni-patterns
-Wno-missing-signatures
-Wno-orphans
-Wno-type-defaults
-Wno-unused-do-bind
'
# if you have need to try building in less memory
GHCLOWMEMFLAGS := ''
# ghc-only builds need the macro definitions generated by cabal
# from cabal's dist or dist-sandbox dir, hopefully there's just one:
#CABALMACROSFLAGS := '-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h'
# or from stack's dist dir:
#CABALMACROSFLAGS := '-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h'
CABALMACROSFLAGS := ''
BUILDFLAGS := '-rtsopts ' + WARNINGS + GHCLOWMEMFLAGS + CABALMACROSFLAGS + ' -DDEVELOPMENT' + ' -DVERSION="' + VERSION + '"' + INCLUDEPATHS
# -fplugin Debug.Breakpoint \
# -fhide-source-paths \
# PROFBUILDFLAGS := '-prof -fprof-auto -osuf hs_p'
TIME := "{{ shell date +'%Y%m%d%H%M' }}"
MONTHYEAR := "{{ shell date +'%B %Y' }}"
# ** Building ------------------------------------------------------------
BUILDING:
# build the hledger package showing ghc codegen times/allocations
@buildtimes:
time ($STACK build hledger --force-dirty --ghc-options='-fforce-recomp -ddump-timings' 2>&1 | grep -E '\bCodeGen \[.*time=')
# # build an unoptimised hledger at bin/hledger.EXT.unopt (default: git describe)
# build-unopt *EXT:
# #!/usr/bin/env bash
# ext={{ if EXT == '' { `git describe --tags` } else { EXT } }}
# exe="bin/hledger.$ext.unopt"
# $STACK --verbosity=error install --ghc-options=-O0 hledger --local-bin-path=bin
# mv bin/hledger "$exe"
# echo "$exe"
# build hledger with profiling enabled at bin/hledgerprof
hledgerprof:
@echo "building bin/hledgerprof..."
{{ STACK }} install --profile --local-bin-path=bin hledger && mv bin/hledger{,prof}
@echo "to profile, use $STACK exec --profile -- hledger ..."
# # build "bin/hledgercov" for coverage reports (with ghc)
# hledgercov:
# $STACK ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs $BUILDFLAGS
# run ghcid on hledger-lib + hledger
@ghcid:
ghcid -c 'just ghci'
# run ghcid autobuilder on hledger-lib + hledger + hledger-ui
@ghcid-ui:
ghcid -c 'just ghci-ui'
# run ghcid autobuilder on hledger-lib + hledger + hledger-web
@ghcid-web:
ghcid -c 'just ghci-web'
# run ghcid autobuilding and running hledger-web with sample journal on port 5001
@ghcid-web-run:
ghcid -c 'just ghci-web' --test ':main -f examples/sample.journal --port 5001 --serve'
# # run ghcid autobuilding and running the test command
# ghcid-test:
# ghcid -c 'just ghci' --test ':main test -- --color=always'
# # run ghcid autobuilding and running the test command with this TESTPATTERN
# ghcid-test-%:
# ghcid -c 'just ghci' --test ':main test -- --color=always -p$*'
# run ghcid autobuilding and running hledger-lib doctests
@ghcid-doctest:
ghcid -c 'cd hledger-lib; $STACK ghci hledger-lib:test:doctest' --test ':main' --reload hledger-lib
GHCIDRESTART := '--restart Makefile --restart Makefile.local'
GHCIDRELOAD := '--reload t.j --reload t.timedot'
GHCIDCMD := ':main -f t.j bal date:today -S'
# # run ghcid autobuilding and running a custom GHCI command with reload/restart on certain files - customise this
# ghcid-watch watch:
# ghcid -c 'just ghci' --test '{{ GHCIDCMD }}' {{ GHCIDRELOAD }} {{ GHCIDRESTART }}
# keep synced with Shake.hs header
SHAKEDEPS := '\
--package base-prelude \
--package directory \
--package extra \
--package process \
--package regex \
--package safe \
--package shake \
--package time \
'
# --package hledger-lib \ # for Hledger.Utils.Debug
# run ghcid autobuilder on Shake.hs
ghcid-shake:
stack exec {{ SHAKEDEPS }} -- ghcid Shake.hs
# ** Testing ------------------------------------------------------------
TESTING:
# run ghci on hledger-lib + hledger
@ghci *GHCIARGS:
$STACKGHCI exec -- $GHCI $BUILDFLAGS {{ GHCIARGS }} hledger/Hledger/Cli.hs
# echo the full command that just ghci would run
@ghci-echo *GHCIARGS:
echo $STACKGHCI exec -- $GHCI $BUILDFLAGS {{ GHCIARGS }} hledger/Hledger/Cli.hs
# run ghci on hledger-lib + hledger with profiling/call stack information
@ghci-prof *GHCIARGS:
stack build --profile hledger --only-dependencies
$STACKGHCI exec -- $GHCI $BUILDFLAGS -fexternal-interpreter -prof -fprof-auto {{ GHCIARGS }} hledger/Hledger/Cli.hs
# run ghcitui on hledger-lib + hledger
@ghcitui *GHCITUIARGS:
ghcitui --cmd "just ghci"
# # run ghci on hledger-lib + hledger + dev.hs script
# @ghci-dev:
# $STACKGHCI exec -- $GHCI $BUILDFLAGS -fno-warn-unused-imports -fno-warn-unused-binds dev.hs
# run ghci on hledger-lib + hledger + hledger-ui
@ghci-ui *GHCIARGS:
$STACKGHCI exec -- $GHCI $BUILDFLAGS {{ GHCIARGS }} hledger-ui/Hledger/UI/Main.hs
# run ghci on hledger-lib + hledger + hledger-web
@ghci-web *GHCIARGS:
$STACKGHCI exec -- $GHCI $BUILDFLAGS {{ GHCIARGS }} hledger-web/app/main.hs
# run ghci on hledger-lib + hledger + hledger-web + hledger-web test suite
@ghci-web-test *GHCIARGS:
$STACKGHCI exec -- $GHCI $BUILDFLAGS {{ GHCIARGS }} hledger-web/test/test.hs
# # better than stack exec ?
# # XXX does not see changes to files
# # run ghci on hledger-lib + test runner
# ghci-lib-test:
# $STACKGHCI ghci --ghc-options="\'-rtsopts {{ WARNINGS }} -ihledger-lib -DDEVELOPMENT -DVERSION=\"1.26.99\"\'" hledger-lib/test/unittest.hs
# run ghci on all the hledger
# ghci-all:
# $STACK exec -- $GHCI $BUILDFLAGS \
# hledger-ui/Hledger/UI/Main.hs \
# hledger-web/app/main.hs \
# run ghci on hledger-lib doctests
@ghci-doctest:
cd hledger-lib; $STACKGHCI ghci hledger-lib:test:doctest
# run ghci on Shake.hs
@ghci-shake:
$STACK exec {{ SHAKEDEPS }} -- ghci Shake.hs
# # hledger-lib/Hledger/Read/TimeclockReaderPP.hs
# # build the dev.hs script for quick experiments (with ghc)
# dev:
# $STACK ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs \
# # to get profiling deps installed, first do something like:
# # stack build --library-profiling hledger-lib timeit criterion
# # build the dev.hs script with profiling support
# devprof:
# $STACK ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs -rtsopts -prof -fprof-auto -osuf p_o -o devprof
# # get a time & space profile of the dev.hs script
# dev-profile:
# time ./devprof +RTS -P \
# && cp devprof.prof devprof.prof.{{ TIME }} \
# && profiterole devprof.prof
# # get heap profiles of the dev.hs script
# dev-heap:
# time ./devprof +RTS -hc -L1000 && cp devprof.hp devprof-hc.hp && hp2ps devprof-hc.hp
# time ./devprof +RTS -hr -L1000 && cp devprof.hp devprof-hr.hp && hp2ps devprof-hr.hp
# dev-heap-upload:
# curl -F "[email protected]" -F "title='hledger parser'" http://heap.ezyang.com/upload
# curl -F "[email protected]" -F "title='hledger parser'" http://heap.ezyang.com/upload
# run tests that are reasonably quick (files, unit, functional) and benchmarks
test: embedtest functest
# For quieter tests add --silent. It may hide troubleshooting info.
# For very verbose tests add --verbosity=debug. It seems hard to get something in between.
STACKTEST := STACK + ' test --fast'
# # When doing build testing, save a little time and output noise by not
# # running tests & benchmarks. Comment this out if you want to run them.
# SKIPTESTSBENCHS := '--no-run-tests --no-run-benchmarks'
# check all files embedded with file-embed are declared in extra-source-files
@embedtest:
tools/checkembeddedfiles
# # stack build --dry-run all hledger packages ensuring an install plan with default snapshot)
# buildplantest:
# buildplantest-stack.yaml
# # stack build --dry-run all hledger packages ensuring an install plan with each ghc version/stackage snapshot
# buildplantest-all:
# for F in stack*.yaml; do make --no-print-directory buildplantest-$F; done
# # stack build --dry-run all hledger packages ensuring an install plan with the given stack yaml file; eg make buildplantest-stack8.2.yaml
# buildplantest-%:
# $STACK build --dry-run --test --bench --stack-yaml=$*
# # force-rebuild all hledger packages/modules quickly ensuring no warnings with default snapshot)
# buildtest:
# buildtest-stack.yaml
# # force-rebuild all hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot
# buildtest-all:
# for F in stack*.yaml; do make --no-print-directory buildtest-$F; done
# # force-rebuild all hledger packages/modules quickly ensuring no warnings with the given stack yaml file; eg make buildtest-stack8.2.yaml
# buildtest-%:
# $STACK build --test --bench {{ SKIPTESTSBENCHS }} --fast --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --stack-yaml=$*
# # build any outdated hledger packages/modules quickly ensuring no warnings with default snapshot. Wont detect warnings in up-to-date modules.)
# incr-buildtest:
# incr-buildtest-stack.yaml
# # build any outdated hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot. Wont detect warnings in up-to-date modules.
# incr-buildtest-all:
# for F in stack*.yaml; do make --no-print-directory incr-buildtest-$F; done
# # build any outdated hledger packages/modules quickly ensuring no warnings with the stack yaml file; eg make buildtest-stack8.2.yaml. Wont detect warnings in up-to-date modules.
# incr-buildtest-%:
# $STACK build --test --bench {{ SKIPTESTSBENCHS }} --fast --ghc-options=-Werror --stack-yaml=$*
# # do a stack clean --full with all ghc versions for paranoia/troubleshooting
# stack-clean-all:
# for F in stack*.yaml; do $STACK clean --full --stack-yaml=$F; done
# run all test suites in the hledger packages
@pkgtest:
($STACKTEST && echo $@ PASSED) || (echo $@ FAILED; false)
# doctest with ghc 8.4 on mac requires a workaround, see hledger-lib/package.yaml.
# Or, could run it with ghc 8.2:
# @($STACKTEST --stack-yaml stack8.2.yaml hledger-lib:test:doctest && echo $@ PASSED) || (echo $@ FAILED; false)
# run the doctests in hledger-lib module/function docs. DOCTESTARGS is passed through but seems not too useful.
@doctest *DOCTESTARGS:
($STACKTEST --ghc-options=-fobject-code --test-arguments="$DOCTESTARGS" hledger-lib:test:doctest && echo $@ PASSED) || (echo $@ FAILED; false)
# # run the unit tests in hledger-lib
# unittest:
# @($STACKTEST hledger-lib:test:unittest && echo $@ PASSED) || (echo $@ FAILED; false)
# run hledger & hledger-lib unit tests (do a stack build hledger first).
@unittest:
($STACK exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false)
SHELLTEST := 'COLUMNS=80 ' + STACK + ' exec -- shelltest --execdir --exclude=/_ --threads=32'
# --hide-successes
# build hledger quickly and run functional tests, with any shelltest OPTS (requires mktestaddons)
@functest *OPTS:
$STACK build hledger
time (({{ SHELLTEST }} {{ if OPTS == '' { '' } else { OPTS } }} \
hledger/test/ bin/ \
-x ledger-compat/ledger-baseline -x ledger-compat/ledger-regress -x ledger-compat/ledger-extra \
&& echo $@ PASSED) || (echo $@ FAILED; false))
ADDONEXTS := 'pl py rb sh hs lhs rkt exe com bat'
ADDONSDIR := 'hledger/test/cli/addons'
# generate dummy add-ons for testing the CLI
mktestaddons:
#!/usr/bin/env sh
rm -rf $ADDONSDIR
mkdir -p $ADDONSDIR $ADDONSDIR/hledger-addondir
cd $ADDONSDIR
printf '#!/bin/sh\necho add-on: $0\necho args: $@\n' > hledger-addon
for E in '' {{ ADDONEXTS }}; do cp hledger-addon hledger-addon.$E; done
for F in addon. addon2 addon2.hs addon3.exe addon3.lhs addon4.exe add reg; do cp hledger-addon hledger-$F; done
chmod +x hledger-*
# compare hledger's and ledger's balance report
compare-balance:
#!/usr/bin/env bash
for f in examples/1txns-1accts.journal \
examples/10txns-10accts.journal \
; do \
(export f=$f; \
printf "\n-------------------------------------------------------------------------------\n"; \
echo "comparing hledger -f $f balance and ledger -f $f balance --flat"; \
difft --color=always --display side-by-side-show-both <(hledger -f $f balance) <(ledger -f $f balance --flat) ) | tail +2; \
done
# generate a hlint report
hlinttest hlint:
hlint --hint=hlint --report=hlint.html {{ SOURCEFILES }}
# check that haddock can generate docs without dying
@haddocktest:
(just -q haddock && echo haddocktest PASSED) || (echo haddocktest FAILED; false)
# check cabal files' syntax
@cabalfilestest:
just cabalfiles
(for p in $PACKAGES; do (cd $p && printf "\nchecking $p.cabal:\n" && cabal check); done \
&& echo $@ PASSED) || (echo $@ FAILED; false)
# test-stack%yaml:
# $STACK --stack-yaml stack$*yaml clean
# $STACK --stack-yaml stack$*yaml build --ghc-options="{{ WARNINGS }} -Werror" --test --bench --haddock --no-haddock-deps
#
# releasetest: Clean unittest functest fullcabaltest haddocktest #buildtest doctest \
# {{ call def-help,releasetest,pre-release tests }}
# run hledger-install.sh not from inside a haskell project
installtest:
cd; {{ justfile_directory() }}/hledger-install/hledger-install.sh
# ** Installing ------------------------------------------------------------
INSTALLING:
# # copy the current ~/.local/bin/hledger to bin/old/hledger-VER
# @copy-as VER:
# cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}"
# install hledger as bin/old/hledger-VER
@installas VER:
$STACK install --local-bin-path bin/old hledger
for e in hledger ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/old/$e-{{ VER }}"; done
# install all hledger executables as bin/old/hledger*-VER
@installallas VER:
$STACK install --local-bin-path bin/old
for e in hledger hledger-ui hledger-web ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/old/$e-{{ VER }}"; done
# install hledger with stack traces and ghc-debug support enabled, as bin/hledger*-dbg
@installasdbg *STACKARGS:
$STACK install --local-bin-path bin --flag '*:debug' {{ STACKARGS }} hledger
for e in hledger ; do mv bin/$e bin/$e-dbg; echo "bin/$e-dbg"; done
# install all hledger executables with stack traces and ghc-debug support enabled, as bin/hledger*-dbg
@installallasdbg *STACKARGS:
$STACK install --local-bin-path bin --flag '*:debug' {{ STACKARGS }}
for e in hledger hledger-ui hledger-web ; do mv bin/$e bin/$e-dbg; echo "bin/$e-dbg"; done
# # make must be GNU Make 4.3+
# .PHONY: shellcompletions
# # update shell completions in hledger package
# shellcompletions:
# make -C hledger/shell-completion/ clean-all all
# On gnu/linux: can't interpolate GTAR here for some reason, and need the shebang line.
# linux / mac only for now, does not handle the windows zip file.
# download github release VER binaries for OS (linux, mac) and ARCH (x64, arm64) to bin/old/hledger*-VER
@installrel VER OS ARCH:
#!/usr/bin/env bash
# if [[ "$OS" == "windows" ]]; then
# cd bin/old && curl -L https://github.com/simonmichael/hledger/releases/download/{{ VER }}/hledger-{{ OS }}-{{ ARCH }}.zip | funzip | `type -P gtar || echo tar` xf - --transform 's/$/-{{ VER }}/'
# else
# fi
cd bin/old && curl -L https://github.com/simonmichael/hledger/releases/download/{{ VER }}/hledger-{{ OS }}-{{ ARCH }}.tar.gz | `type -P gtar || echo tar` xzf - --transform 's/$/-{{ VER }}/'
# # download recent versions of the hledger executables from github to bin/hledger*-VER
# get-recent-binaries:
# for V in 1.32.2 1.31 1.30 1.29.2 1.28 1.27.1; do just get-binaries $OS x64 $V; done
# just symlink-binaries
# # add easier symlinks for all the minor hledger releases downloaded by get-binaries.
# symlink-binaries:
# just symlink-binary 1.32.2
# just symlink-binary 1.29.2
# just symlink-binary 1.27.1
# add an easier symlink for this minor hledger release (hledger-1.29 -> hledger-1.29.2, etc.)
@symlink-binary MINORVER:
cd bin && ln -sf hledger-$MINORVER hledger-`echo $MINORVER | sed -E 's/\.[0-9]+$//'`
# sym-link some directories required by hledger-web dev builds
symlink-web-dirs:
echo "#ln -sf hledger-web/config # disabled, causes makeinfo warnings"
ln -sf hledger-web/messages
ln -sf hledger-web/static
ln -sf hledger-web/templates
# update shell completions in hledger package
shell-completions:
make -C hledger/shell-completion/ clean-all all
# ** Benchmarking ------------------------------------------------------------
BENCHMARKING:
# generate standard sample journals in examples/
samplejournals:
# small journals
tools/generatejournal 3 5 5 > examples/ascii.journal
tools/generatejournal 3 5 5 --mixed > examples/mixed.journal
tools/generatejournal 1 1 10 > examples/1txns-1accts.journal
tools/generatejournal 10 10 10 > examples/10txns-10accts.journal
tools/generatejournal 100 100 10 > examples/100txns-100accts.journal
# many transactions
tools/generatejournal 1000 1000 10 > examples/1ktxns-1kaccts.journal
tools/generatejournal 2000 1000 10 > examples/2ktxns-1kaccts.journal
tools/generatejournal 3000 1000 10 > examples/3ktxns-1kaccts.journal
tools/generatejournal 4000 1000 10 > examples/4ktxns-1kaccts.journal
tools/generatejournal 5000 1000 10 > examples/5ktxns-1kaccts.journal
tools/generatejournal 6000 1000 10 > examples/6ktxns-1kaccts.journal
tools/generatejournal 7000 1000 10 > examples/7ktxns-1kaccts.journal
tools/generatejournal 8000 1000 10 > examples/8ktxns-1kaccts.journal
tools/generatejournal 9000 1000 10 > examples/9ktxns-1kaccts.journal
tools/generatejournal 10000 1000 10 > examples/10ktxns-1kaccts.journal
tools/generatejournal 20000 1000 10 > examples/20ktxns-1kaccts.journal
tools/generatejournal 30000 1000 10 > examples/30ktxns-1kaccts.journal
tools/generatejournal 40000 1000 10 > examples/40ktxns-1kaccts.journal
tools/generatejournal 50000 1000 10 > examples/50ktxns-1kaccts.journal
tools/generatejournal 60000 1000 10 > examples/60ktxns-1kaccts.journal
tools/generatejournal 70000 1000 10 > examples/70ktxns-1kaccts.journal
tools/generatejournal 80000 1000 10 > examples/80ktxns-1kaccts.journal
tools/generatejournal 90000 1000 10 > examples/90ktxns-1kaccts.journal
tools/generatejournal 100000 1000 10 > examples/100ktxns-1kaccts.journal
tools/generatejournal 1000000 1000 10 > examples/1Mtxns-1kaccts.journal
# many accounts
tools/generatejournal 1000 1 10 > examples/1ktxns-1accts.journal
tools/generatejournal 1000 10 10 > examples/1ktxns-10accts.journal
tools/generatejournal 1000 100 10 > examples/1ktxns-100accts.journal
#tools/generatejournal 1000 1000 10 > examples/1ktxns-1kaccts.journal
tools/generatejournal 1000 10000 10 > examples/1ktxns-10kaccts.journal
tools/generatejournal 1000 100000 10 > examples/1ktxns-100kaccts.journal
tools/generatejournal 1000 1000000 10 > examples/1ktxns-1maccts.journal
tools/generatejournal 10000 1 10 > examples/10ktxns-1accts.journal
tools/generatejournal 10000 10 10 > examples/10ktxns-10accts.journal
tools/generatejournal 10000 100 10 > examples/10ktxns-100accts.journal
#tools/generatejournal 10000 1000 10 > examples/10ktxns-1kaccts.journal
tools/generatejournal 10000 10000 10 > examples/10ktxns-10kaccts.journal
tools/generatejournal 10000 20000 10 > examples/10ktxns-20kaccts.journal
tools/generatejournal 10000 30000 10 > examples/10ktxns-30kaccts.journal
tools/generatejournal 10000 40000 10 > examples/10ktxns-40kaccts.journal
tools/generatejournal 10000 50000 10 > examples/10ktxns-50kaccts.journal
tools/generatejournal 10000 60000 10 > examples/10ktxns-60kaccts.journal
tools/generatejournal 10000 70000 10 > examples/10ktxns-70kaccts.journal
tools/generatejournal 10000 80000 10 > examples/10ktxns-80kaccts.journal
tools/generatejournal 10000 90000 10 > examples/10ktxns-90kaccts.journal
tools/generatejournal 10000 100000 10 > examples/10ktxns-100kaccts.journal
tools/generatejournal 10000 1000000 10 > examples/10ktxns-1maccts.journal
# The current OS name, in the form used for hledger release binaries: linux, mac, windows or other.
# can't use $GHC or {{GHC}} here for some reason
OS := `ghc -ignore-dot-ghci -package-env - -e 'import System.Info' -e 'putStrLn $ case os of "darwin"->"mac"; "mingw32"->"windows"; "linux"->"linux"; _->"other"'`
# tools/generatejournal.hs 3 5 5 --chinese > examples/chinese.journal # don't regenerate, keep the simple version
# $ just --set BENCHEXES ledger,hledger bench
# run the benchmark commands in bench.sh with quickbench. Eg: just bench -h; just bench -f bench10k.sh -w hledger-1.30,hledger-1.31,hledger-1.32 -n2 -N2
@bench *ARGS:
printf "Running quick benchmarks (times are approximate, can be skewed):\n"
which quickbench >/dev/null && quickbench {{ ARGS }} || echo "quickbench not installed (see bench.sh), skipping"
# @bench-gtime:
# for args in '-f examples/10ktxns-1kaccts.journal print' '-f examples/100ktxns-1kaccts.journal register' '-f examples/100ktxns-1kaccts.journal balance'; do \
# echo; \
# for app in hledger-1.26 hledger-21ad ledger; do \
# echo; echo $app $args:; \
# gtime $app $args >/dev/null; \
# done; \
# done
# show throughput at various data sizes with the given hledger executable (requires samplejournals)
@bench-throughput EXE:
echo date: `date`
echo system: `uname -a`
echo executable: {{ EXE }}
echo version: `{{ EXE }} --version`
for n in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 100000 ; do \
printf "%6d txns: " $n; {{ EXE }} stats -f examples/${n}x1000x10.journal | tail -1; \
done
date
# show throughput at various data sizes with the latest hledger dev build, optimised or not (requires samplejournals)
@bench-throughput-dev:
stack build hledger
stack exec -- just throughput hledger
# show throughput of recent hledger versions (requires samplejournals)
@bench-throughput-recent:
for v in 1.25 1.28 1.29 1.32 1.32.3; do printf "\nhledger-$v:\n"; for i in `seq 1 3`; do hledger-$v -f examples/10ktxns-10kaccts.journal stats | grep throughput; done; done
# @bench-balance-many-accts:
# quickbench -w hledger-1.26,hledger-21ad,ledger -f bench-many-accts.sh -N2
# #quickbench -w hledger-1.25,hledger-1.28,hledger-1.29,hledger-1.30,hledger-1.31,hledger-1.32,hledger-21ad,ledger -f bench-many-accts.sh -N2
# @bench-balance-many-txns:
# quickbench -w hledger-21ad,ledger -f bench-many-txns.sh -N2
# samplejournals bench.sh
# bench: samplejournals tests/bench.tests tools/simplebench \
# $(call def-help,bench,\
# run simple performance benchmarks and archive results\
# Requires some commands defined in tests/bench.tests and some BENCHEXES defined above.\
# )
# tools/simplebench -v -ftests/bench.tests $(BENCHEXES) | tee doc/profs/$(TIME).bench
# @rm -f benchresults.*
# @(cd doc/profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench)
# criterionbench: samplejournals tools/criterionbench \
# $(call def-help,criterionbench,\
# run criterion benchmark tests and save graphical results\
# )
# tools/criterionbench -t png -k png
# progressionbench: samplejournals tools/progressionbench \
# $(call def-help,progressionbench,\
# run progression benchmark tests and save graphical results\
# )
# tools/progressionbench -- -t png -k png
# # prof: samplejournals \
# # $(call def-help,prof,\
# # generate and archive an execution profile\
# # ) #bin/hledgerprof
# # @echo "Profiling: $(PROFCMD)"
# # -$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS
# # mv hledgerprof.prof doc/profs/$(TIME).prof
# # (cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof)
# # viewprof: prof \
# # $(call def-help,viewprof,\
# # generate, archive, simplify and display an execution profile\
# # )
# # tools/simplifyprof.hs doc/profs/latest.prof
#{{ STACK }} exec --profile -- hledger +RTS {{ PROFRTSFLAGS }} -RTS -f examples/1000x1000x10.journal {{ CMD }} #>/dev/null
# run a hledger CMD against a sample journal and display the execution profile (build hledgerprof first)
quickprof CMD: #hledgerprof #samplejournals
hledgerprof +RTS {{ PROFRTSFLAGS }} -RTS -f examples/10ktxns-1kaccts.journal {{ CMD }} #>/dev/null
@profiterole hledger.prof
@echo
@head -20 hledger.prof
@echo ...
@echo
@head -20 hledger.profiterole.txt
@echo ...
@echo
@echo "See hledger.prof, hledger.profiterole.txt, hledger.profiterole.html for more."
# generate and archive a graphical heap profile
@heap: hledgerprof #samplejournals
echo "Profiling heap with: $PROFCMD"
{{ PROFCMD }} +RTS -hc -RTS
mv hledgerprof.hp doc/profs/$(TIME).hp
(cd doc/profs; rm -f latest.hp; ln -s {{ TIME }}.hp latest.hp; \
hp2ps {{ TIME }}.hp; rm -f latest.ps; ln -s {{ TIME }}.ps latest.ps; rm -f *.aux)
# # viewheap: heap \
# # $(call def-help,viewheap,\
# # \
# # )
# # $(VIEWPS) doc/profs/latest.ps
# quickheap-%: hledgerprof samplejournals \
# $(call def-help,quickheap-"CMD", run some command against a sample journal and display the heap profile )
# $(STACK) exec -- hledgerprof +RTS -hc -RTS $* -f examples/10000x1000x10.journal >/dev/null
# hp2ps hledgerprof.hp
# @echo generated hledgerprof.ps
# $(VIEWPS) hledgerprof.ps
# # quickcoverage: hledgercov \
# # $(call def-help,quickcoverage,\
# # display a code coverage text report from running hledger COVCMD\
# # )
# # @echo "Generating code coverage text report for hledger command: $(COVCMD)"
# # tools/runhledgercov "report" $(COVCMD)
# # coverage: samplejournals hledgercov \
# # $(call def-help,coverage,\
# # generate a code coverage html report from running hledger COVCMD\
# # )
# # @echo "Generating code coverage html report for hledger command: $(COVCMD)"
# # tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD)
# # cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html
# # viewcoverage: \
# # $(call def-help,viewcoverage,\
# # view the last html code coverage report\
# # )
# # $(VIEWHTML) doc/profs/coverage/index.html
# ** Documenting ------------------------------------------------------------
DOCUMENTING:
# see also Shake.hs
# http://www.haskell.org/haddock/doc/html/invoking.html
# update the website (the live one if run on hledger.org)
site: #Shake
./Shake -V site 2>&1 | tee -a site.log
# Use the existing Shake executable without recompiling it, so as not to automatially run unreviewed code by hook ? I think this no longer applies.
# site: $(call def-help,site-build, update the hledger.org website (run this on hledger.org, or run "make hledgerorg" elsewhere) )
# @[ ! -x Shake ] \
# && echo 'Please run "make Shake" first (manual compilation required for safety)' \
# || ( \
# echo; \
# ./Shake -V site; \
# ) 2>&1 | tee -a site.log
BROWSEDELAY := '5'
#LOCALSITEURL := 'http://localhost:3000/dev/hledger.html'
LOCALSITEURL := 'http://localhost:3000/index.html'
# open a browser on the website (in ./site) and rerender when docs or web pages change
@site-watch: #Shake
(printf "\nbrowser will open in {{ BROWSEDELAY }}s (adjust BROWSE if needed)...\n\n"; sleep $BROWSEDELAY; $BROWSE "$LOCALSITEURL" ) &
$WATCHEXEC --print-events -e md,m4 -i hledger.md -i hledger-ui.md -i hledger-web.md -r './Shake webmanuals && ./Shake orgfiles && make -sC site serve'
STACKHADDOCK := 'time ' + STACK + ' --verbosity=error haddock --fast --no-keep-going \
--only-locals --no-haddock-deps --no-haddock-hyperlink-source \
--haddock-arguments="--no-warnings" \
'
# -ghc-options='-optP-P' # workaround for http://trac.haskell.org/haddock/ticket/284
HADDOCKPKGS := 'hledger-lib'
# regenerate haddock docs for the hledger packages
haddock:
{{ STACKHADDOCK }} {{ HADDOCKPKGS }}
# regenerate haddock docs for the hledger packages and open them
@haddock-and-open:
just haddock
just haddock-open
# # Rerenders all hledger packages. Run make haddock-open to open contents page.
# haddock-watch1: \
# $(call def-help,haddock-watch, regenerate haddock docs when files change )
# $(STACKHADDOCK) $(HADDOCK_PKGS) --file-watch --exec='echo done'
# # Rerenders hledger-lib modules, opens hledger-lib contents page.
# haddock-watch2: \
# $(call def-help,haddock-watch2, regenerate hledger-lib haddock docs when files change )
# watchexec -r -e yaml,cabal,hs --print-events -- \
# $(STACKHADDOCK) --verbosity=info $(HADDOCK_PKGS) --exec="'echo done'" hledger-lib --open
# # Rerenders/reopens the Hledger module, without submodules. (Fastest)
# haddock-watch: \
# $(call def-help,haddock-watch3, quickly regenerate & reload Hledger.hs haddock when files change )
# watchexec -r -e yaml,cabal,hs --print-events --shell=none -- bash -c 'mkdir -p tmp && rm -f tmp/Hledger.html && haddock -h -o tmp hledger-lib/Hledger.hs --no-warnings --no-print-missing-docs 2>&1 | grep -v "Could not find documentation" && open tmp/Hledger.html'
# open the haddock packages contents page in a browser
haddock-open:
{{ BROWSE }} `$STACK path --local-install-root`/doc/index.html
# hoogle-setup: $(call def-help,hoogle-setup, install hoogle then build haddocks and a hoogle db for the project and all deps )
# stack hoogle --rebuild
# HOOGLEBROWSER="/Applications/Firefox Dev.app/Contents/MacOS/firefox" # safari not supported
# hoogle-serve: $(call def-help,hoogle-serve, run hoogle web app and open in browser after doing setup if needed )
# $(HOOGLEBROWSER) http://localhost:8080 &
# stack --verbosity=warn hoogle --server
# # sourcegraph: \
# # $(call def-help,sourcegraph,\
# # \
# # )
# # for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done
# manuals-watch: Shake \
# $(call def-help,manuals-watch, rerender manuals when their source files change )
# ls $(DOCSOURCEFILES) | entr ./Shake -VV manuals
# man-watch: man-watch-hledger \
# $(call def-help,man-watch, run man on the hledger man page when its source file changes )
# man-watch-%: Shake \
# $(call def-help,man-watch-PROG, run man on the given man page when its source file changes. Eg make man-watch-hledger-web )
# $(WATCHEXEC) -r -w $*/$*.m4.md './Shake $*/$*.1 && man $*/$*.1'
# shakehelp-watch: \
# $(call def-help,shakehelp-watch, rerender Shake.hs's help when it changes)
# ls Shake.hs | entr -c ./Shake.hs
# # The following rule, for updating the website, gets called on hledger.org by:
# # 1. github-post-receive (github webhook handler), when something is pushed
# # to the main or wiki repos on Github. Config:
# # /etc/supervisord.conf -> [program:github-post-receive]
# # /etc/github-post-receive.conf
# # 2. cron, nightly. Config: /etc/crontab
# # 3. manually: "make site" on hledger.org, or "make hledgerorg" elsewhere (cf Makefile.local).
# optimise and commit RELEASING value map diagram
@releasediag:
pngquant doc/HledgerReleaseValueMap.png -f -o doc/HledgerReleaseValueMap.png
git add doc/HledgerReleaseValueMap.png
git commit -m ';doc: RELEASING: update value map' -- doc/HledgerReleaseValueMap.png
CHANGELOGS := 'CHANGES.md hledger/CHANGES.md hledger-ui/CHANGES.md hledger-web/CHANGES.md hledger-lib/CHANGES.md'
# Show changes since last release in the given CHANGES.md file or all of them. (Run after ./Shake changelogs.)
unreleased *CHANGELOG:
#!/usr/bin/env osh
if [[ -z $CHANGELOG ]]; then
for CHANGELOG in $CHANGELOGS; do
printf "** $CHANGELOG\n\n"
just unreleased $CHANGELOG
echo
done
else
awk '/^#+ /{p=1};/^#+ +[0-9]+\.[0-9].*([0-9]{4}-[0-9]{2}-[0-9]{2})/{exit};p' $CHANGELOG
fi
# Commit and push FAQ edits.
pushfaq:
(cd ~/src/hledger/site; git commit -m 'faq' src/faq.md; git push)
# ** News ------------------------------------------------------------
NEWS:
# # Convert DATEARG to an ISO date. It can be an ISO date, number of recent days, or nothing (meaning last release date).
# @_datearg *DATEARG:
# echo {{ if DATEARG == '' { `just reldate` } else { if DATEARG =~ '^\d+$' { `dateadd $(date +%Y-%m-%d) -$DATEARG` } else { DATEARG } } }}
#dateround := 'dateround -n'
dateround := 'dateround'
# If DATE is provided, return it, otherwise the date two fridays ago.
@_dateorsecondlatestfriday *DATE:
echo {{ if DATE == '' { `gdate -I -d "$($dateround today -- -fri) - 1 week"` } else { DATE } }}
# If DATE is provided, return today's date, otherwise the most recent friday's (possibly today).
@_todayorlatestfriday *DATE:
echo {{ if DATE == '' { `$dateround today -- -fri` } else { `$GDATE -I` } }}
# If DATE is provided, return tomorrow's date, otherwise last friday's.
@_tomorroworlatestfriday *DATE:
echo {{ if DATE == '' { `$dateround today -- -fri` } else { `$GDATE -I -d tomorrow` } }}
# Show a draft This Week In Hledger post, with activity between the last two fridays (by default)
twih: # *DATE:
#!/usr/bin/env osh
#BEG=`just _dateorsecondlatestfriday $DATE`
END=`just _todayorlatestfriday $DATE`
cat <<EOS
== TWIH notes: ========================================
last release: `just rel`
`gcal`
`just timelog $DATE`
`just worklog $DATE`
recent issue activity:
https://github.com/simonmichael/hledger/issues?q=sort:updated-desc
== TWIH draft (in clipboard) : ========================
EOS
(cat <<EOS
---
## This Week In Hledger $END
**sm**
`just commitlog $DATE`
**Misc**
recent discussions: <https://hledger.org/support.html>
**Quotes**
- **
- **
<https://hledger.org/news.html#this-week-in-hledger-$END>
EOS
) | tee /dev/tty | pbcopy
GITSHORTFMT := "--format='%ad %s' --date=short"
# Show commits briefly in the three hledger repos between the last two fridays or since this date
commitlog *DATE:
#!/usr/bin/env osh
BEG=`just _dateorsecondlatestfriday $DATE`