-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJustfile
More file actions
174 lines (137 loc) · 4.82 KB
/
Copy pathJustfile
File metadata and controls
174 lines (137 loc) · 4.82 KB
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
#rg := 'rg -IN --sort=path'
sed := 'gsed -E'
hledger := 'hledger -n'
hledgerc := 'hledger -f main.journal'
downloads := '/Users/simon/Downloads'
occsvsrc := downloads / 'hledger-transactions.csv'
csv := 'data/oc.csv'
checks := 'accounts commodities balanced ordereddates'
open := 'open'
# Make constants and recipe arguments available as environment variables.
# (But {{ VAR }} handles multi-word values better.)
set export := true
# By default, list this justfile's commands, optionally filtered by case-insensitive REGEX
@_help *REGEX:
if [[ '{{ REGEX }}' =~ '' ]]; then just -ul; else just -ul --color=always | rg -i '{{ REGEX }}'; true; fi
alias h := _help
# Check this justfile for errors and non-standard format
@_chk:
just --fmt --unstable --check
alias chk := _chk
# If this justfile is error free but in non-standard format, reformat it
@_fmt:
just -q chk || just -q --fmt --unstable
alias fmt := _fmt
# maintenance
# Open the opencollective transactions page for downloading csv
[group('maintenance')]
@csv:
$open 'https://opencollective.com/hledger/transactions?kind=ALL'
read -p 'After successful download, press enter to move the csv file: '
just csvmv
# Moved the downloaded csv here, if any.
[group('maintenance')]
@csvmv:
if [[ -f $occsvsrc ]]; then mv $occsvsrc $csv; else echo "no new $occsvsrc found"; fi
# Regenerate and check journals, update readme reports
[group('maintenance')]
@update: _journal _accounts _check _readme
# Review the cli reports and opencollective budget page
[group('maintenance')]
@review: oc-budget
hledger reports
# Commit all that's committable
[group('maintenance')]
@commit:
-git commit -m "oc csv" -- data/oc.csv
-git commit -m "journals" -- *.journal
-git commit -m "reports" -- README.md
# All of the above. except opening the csv page.
[group('maintenance')]
@process:
just csvmv update commit
# Publish latest commits
[group('maintenance')]
@push:
git push
# steps
# Regenerate OC journal from OC csv
[group('steps')]
@_journal:
($hledger -f $csv --rules oc.csv.rules print -x --round=soft >.oc.journal && mv .oc.journal oc.journal) \
|| (rm -f .oc.journal; false)
# Declare any new accounts found, preserving existing declaration order
[group('steps')]
@_accounts:
((cat accounts.journal; $hledgerc accounts --undeclared --directives) >.accounts.journal && mv .accounts.journal accounts.journal) \
|| (rm -f .accounts.journal; false)
# Check the journal for problems
[group('steps')]
@_check:
printf "checking journal.. "
$hledgerc check $checks && echo "all ok ✅"
# Update reports in README.md
[group('steps')]
@_readme:
$sed '/<!-- REPORTS:/q' README.md >.README.md
hledger ytdrx -Ohtml >>.README.md
hledger yrx -Ohtml >>.README.md
hledger yal -Ohtml >>.README.md
$sed -z 's/(<link[^>]+>)*<style>[^>]+>(<link[^>]+>)*/\n\n/g' <.README.md >README.md # XXX remove HTML reports' CSS (handling hledger version variations)
rm -f .README.md
# Preview the rendered readme
[group('steps')]
@_readme-preview:
pandoc README.md -o .README.html && $open .README.html
# misc
# Report hours of review work per month.
[group('misc')]
@review-hours *ARGS:
hledger -f $TIMELOG bal hl.review -M --transpose {{ ARGS }}
# Open the opencollective page, for invoicing.
[group('misc')]
@oc:
$open 'https://opencollective.com/hledger'
# Open the opencollective expenses page, for approving.
[group('misc')]
@oc-expenses:
$open 'https://opencollective.com/hledger/expenses'
# Show reports
[group('misc')]
@reports:
hledger reports
# Open the opencollective page, budget section.
[group('misc')]
@oc-budget:
$open 'https://opencollective.com/hledger#category-BUDGET'
# Open sm's liberapay ledger
[group('misc')]
@li-ledger:
$open https://liberapay.com/simonmichael/ledger
# Open liberapay receiving page for sm
[group('misc')]
@li-rx-sm:
$open https://liberapay.com/simonmichael/receiving
# Open liberapay receiving page for hledger
[group('misc')]
@li-rx-hledger:
$open https://liberapay.com/hledger/receiving
# Download liberapay patrons as csv
[group('misc')]
@li-csv: _li-pub _li-active _li-all
# Download liberapay public active patrons
[group('misc')]
@_li-pub:
wget -O data/liberapay-public-active-patrons-simonmichael-`date -I`.csv https://liberapay.com/simonmichael/patrons/public.csv
# Download liberapay active patrons
[group('misc')]
@_li-active:
$open 'https://liberapay.com/simonmichael/patrons/export.csv?scope=active'
read -p 'After successful download, press enter: '
mv $downloads/liberapay-active-patrons-simonmichael-*.csv data
# Download liberapay patrons from last 10 years
[group('misc')]
@_li-all:
$open 'https://liberapay.com/simonmichael/patrons/export.csv?scope=all'
read -p 'After successful download, press enter: '
mv $downloads/liberapay-patrons-simonmichael-*.csv data