syntax pipes
This commit is contained in:
parent
25113cbaa2
commit
81339fdff3
1 changed files with 20 additions and 17 deletions
|
@ -6,13 +6,13 @@ def append-if [cond: bool, item: any] {
|
||||||
}
|
}
|
||||||
|
|
||||||
def get-chunked-key [keyid?: string] {
|
def get-chunked-key [keyid?: string] {
|
||||||
let flags = [
|
let flags = ["--export-secret-key", "--export-options", "export-minimal"]
|
||||||
"--export-secret-key", "--export-options", "export-minimal"
|
| append-if ($keyid != null) $keyid
|
||||||
] | append-if ($keyid != null) $keyid
|
|
||||||
let key = (gpg ...$flags)
|
let key = (gpg ...$flags)
|
||||||
let length = ($key | bytes length)
|
let length = ($key | bytes length)
|
||||||
# 1555 is the maximum length in bytes split data evenly
|
# 1555 is the maximum length in bytes
|
||||||
let n = ($length / (($length / 1555)| math ceil)) | math ceil
|
let n = ($length / (($length / 1555)| math ceil)) | math ceil
|
||||||
|
|
||||||
0..$n..$length
|
0..$n..$length
|
||||||
| each {|i| $key | bytes at $i..<($i + $n)}
|
| each {|i| $key | bytes at $i..<($i + $n)}
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,15 @@ def main [keyid?: string, --output(-o) = "dmtxdata.pdf"] {
|
||||||
let tmpdir = mktemp -d -p . -t tmp.key-2-matrix-XXX
|
let tmpdir = mktemp -d -p . -t tmp.key-2-matrix-XXX
|
||||||
let byte_chunks = get-chunked-key $keyid
|
let byte_chunks = get-chunked-key $keyid
|
||||||
|
|
||||||
$byte_chunks | enumerate | each {|it|
|
$byte_chunks
|
||||||
$it.item | dmtxwrite -e 8 -o ($tmpdir | path join $"dmtx-($it.index).svg")
|
| enumerate
|
||||||
|
| each {|it|
|
||||||
|
$it.item
|
||||||
|
| dmtxwrite -e 8 -o ($tmpdir | path join $"dmtx-($it.index).svg")
|
||||||
}
|
}
|
||||||
|
|
||||||
let doc = generate-typst-doc $tmpdir ($byte_chunks | length)
|
generate-typst-doc $tmpdir ($byte_chunks | length)
|
||||||
$doc | typst compile - $output
|
| typst compile - $output
|
||||||
|
|
||||||
rm -r $tmpdir
|
rm -r $tmpdir
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue