-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjustfile
More file actions
31 lines (25 loc) · 850 Bytes
/
justfile
File metadata and controls
31 lines (25 loc) · 850 Bytes
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
set quiet := true
set shell := ["bash", "-cu"]
# Generate invoice and open the produced PDF
service: (_make-and-open "cargo run --bin klirr invoice")
# Show CLI help for the invoice binary
help:
cargo run --bin klirr -- --help
# Generate expenses invoice and open the produced PDF
expense: (_make-and-open "cargo run --bin klirr invoice expenses")
# Usage: `just ooo 5`
ooo days_off: (_make-and-open ("klirr invoice services-off --unit days --quantity " + days_off))
_make-and-open cmd:
#!/usr/bin/env bash
set -euo pipefail
tmp_output="$(mktemp)"
cleanup() { rm -f "$tmp_output"; }
trap cleanup EXIT
if TMP_FILE_FOR_PATH_TO_PDF="$tmp_output" {{cmd}}; then
output_path="$(cat "$tmp_output")"
open "$output_path"
else
exit_code=$?
echo "Error: command failed with exit code $exit_code"
exit "$exit_code"
fi