Fork me on GitHub
#yamlscript
<
2024-04-29
>
Daniel Craig13:04:14

Is there any example code of using external libraries in yamlscript?

Ingy döt Net11:04:49

I have an example of using a babashka Pod from YS. I'll see if I can find it.

Ingy döt Net11:04:03

Here's an example of using a bb Pod in ys:

$ cat pod-test.ys 
!yamlscript/v0

use-pod: \'org::babashka/go-sqlite3 "0.2.3"

require pod::babashka::go-sqlite3: => sqlite

say:
  sqlite/query:
    .":memory:"
    ["SELECT 41 + 1 AS sum"]
The pod is autoinstalled on first run:
$ ys pod-test.ys 
Downloading pod org.babashka/go-sqlite3 (0.2.3)
Successfully installed pod org.babashka/go-sqlite3 (0.2.3)
[{:sum 42}]
And then subsequently:
$ time ys pod-test.ys 
[{:sum 42}]

real    0m0.040s
user    0m0.014s
sys     0m0.028s

Ingy döt Net11:04:10

I want to spend more time on making it even easier to use external libraries and pods. @USDPTD3FY if you (or anyone) has specific needs, let me know. It's always good to have a "customer" driving implementation.... 🙂

Daniel Craig13:04:33

Thanks for the response on my GH issue

👍 1
Ingy döt Net11:04:03

Here's an example of using a bb Pod in ys:

$ cat pod-test.ys 
!yamlscript/v0

use-pod: \'org::babashka/go-sqlite3 "0.2.3"

require pod::babashka::go-sqlite3: => sqlite

say:
  sqlite/query:
    .":memory:"
    ["SELECT 41 + 1 AS sum"]
The pod is autoinstalled on first run:
$ ys pod-test.ys 
Downloading pod org.babashka/go-sqlite3 (0.2.3)
Successfully installed pod org.babashka/go-sqlite3 (0.2.3)
[{:sum 42}]
And then subsequently:
$ time ys pod-test.ys 
[{:sum 42}]

real    0m0.040s
user    0m0.014s
sys     0m0.028s