jsq: upgrade to 2

compiled executable goes brrr
This commit is contained in:
ptrcnull 2022-06-20 21:37:47 +02:00
parent 7730c02488
commit 94703e9182
Signed by: ptrcnull
GPG key ID: 411F7B30801DD9CA
3 changed files with 45 additions and 17 deletions

View file

@ -1,20 +1,36 @@
# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=jsq
pkgver=1
pkgver=2
pkgrel=0
pkgdesc="QuickJS-based jq-like data processing tool"
url="https://git.ddd.rip/ptrcnull/ptrcports"
arch="noarch"
arch="all"
license="BSD-2-Clause"
depends="quickjs"
source="jsq"
makedepends="quickjs"
source="jsq.js"
builddir="$srcdir"
options="!check" # nice
build() {
qjsc -o jsq \
-flto \
-fno-date \
-fno-proxy \
-fno-promise \
-fno-module-loader \
-fno-bigint \
jsq.js
}
check() {
out=$(echo '{"test":"passed"}' | ./jsq ".test")
[ "$out" = "passed" ]
}
package() {
install -Dm755 jsq -t "$pkgdir"/usr/bin
}
sha512sums="
a1404bb221f1b42efcba3973fca5aff4525b0e0e37b32f5a53f57eeb2eae5a90d419c7434e9a7818c96c79e0d96b5be2d80dc2af8e7bc38344b9b8d5b7590e46 jsq
01453f4dfcf0263b37c7c87c0d7c220efe210c3d03ef36c06aa7001bcf97b490bd17953df15a5dc3d88603da1f8498010b2c1ba5659b706e64df6d9b862b0dd9 jsq.js
"

11
jsq/jsq
View file

@ -1,11 +0,0 @@
#!/bin/sh
exec qjs --std -e "
var input = JSON.parse(std.in.readAsString())
var output = input$@;
if (typeof output === 'object') {
console.log(JSON.stringify(output, null, 2))
} else {
console.log(output)
}
"

23
jsq/jsq.js Normal file
View file

@ -0,0 +1,23 @@
import * as std from "std"
// helper stuff
var url = (text, link) => `\x1b]8;;${link}\x1b\\${text}\x1b]8;;\x1b\\`
var colors = {
reset: `\x1b[0m`,
black: `\x1b[30m`,
red: `\x1b[31m`,
green: `\x1b[32m`,
yellow: `\x1b[33m`,
blue: `\x1b[34m`,
magenta: `\x1b[35m`,
cyan: `\x1b[36m`,
white: `\x1b[37m`,
}
var input = JSON.parse(std.in.readAsString())
var output = eval('input' + scriptArgs.slice(1).join(' '));
if (typeof output === "object") {
console.log(JSON.stringify(output, null, 2))
} else {
console.log(output)
}