joker

Discuss all things joker, the Clojure interpreter/linter on top of Go. https://github.com/candid82/joker
hlship 2019-11-07T01:17:22.034500Z

I've noticed that joker.tools.cli, when a :parse-fn throws an exception, outputs the full exception, rather than just the message.

> lacinia-timing -f xyz
lacinia-timing [OPTIONS] [INPUT-FILE]

Reads JSON output from a Lacinia GraphQL query and summarizes the timing.

INPUT-FILE may be "-" to read from standard input.
  -f, --filter MS  Remove timings with duration less than specified value
  -h, --help       This command summary

Errors:
  Error while parsing option "-f xyz": <joker.tools.cli>:228:28: Eval error: strconv.Atoi: parsing "xyz": invalid syntax
Stacktrace:
  global /Users/hlship/workspaces/walmart/cph-tools/lacinia-timing:190:1
  lacinia-timing/command /Users/hlship/workspaces/walmart/cph-tools/lacinia-timing:175:52
  joker.tools.cli/parse-opts <joker.tools.cli>:545:23
  joker.tools.cli/parse-option-tokens <joker.tools.cli>:271:9
  core/reduce <joker.core>:740:17
  f <joker.tools.cli>:274:35
  joker.tools.cli/parse-optarg <joker.tools.cli>:248:9
  joker.tools.cli/parse-value <joker.tools.cli>:228:28

👍 1
jcburley 2019-11-07T13:52:18.041400Z

Not sure whether this is relevant, and I haven't looked into whether it's truly practical, but: I'd like to see Joker use the underlying Go error type (the panic/recover mechanism) more directly, rather than stringizing back and forth as it seems to do right now.

jcburley 2019-11-07T13:53:18.041600Z

Also, as this Slack channel isn't archived anywhere accessible (that's not funded), maybe turn this and your other wish-list items into Issues at https://github.com/candid82/joker/issues?

hlship 2019-11-07T01:23:58.036Z

Wish list for Joker: - Ability to send multiple HTTP requests in parallel - Easy way to assemble a series of OS commands that pipe into each other (e.g., os/exec on steroids) - A few missing math functions, like floor and round

👍 1
jcburley 2019-11-07T16:10:52.042Z

Submitted https://github.com/candid82/joker/pull/290 which (among other things) adds floor and ceil. Might add more (such as round) later as I go through the math package in Go.

jcburley 2019-11-07T17:12:53.042300Z

Just did a bunch more, including round. That PR doesn't add any of the trig nor Bessel functions, nor the MAX/MIN constants. Not sure whether anyone will want any of those, but they're all easy (if a tad tedious) to add.

jcburley 2019-11-07T17:37:49.042600Z

Note that, if you want to do any more of these yourself, they're usually fairly easy. But the PR includes changes to auto-generated files (named a_*.go), which you should ignore when reviewing such changesets.

hlship 2019-11-07T01:25:43.037400Z

The OS piping thing is pretty important IMO. Having Joker script to orchestrate things, but let Unix power tools do the actual work is very sweet. Right now, you kind of have to run each command individually and supply input and capture output as complete strings (though Roman added a little to that recently).

👍 1
hlship 2019-11-07T01:29:19.037600Z

Something like:

(let [result (os/pipe
               [["jq" {:args ["-C" url]}]
                ["gron" {:args "-c"}]
                ["less"]])])

👍 1
jcburley 2019-11-07T13:54:13.041800Z

That would be so cool, IMO. Worth an issue (as I think your others are): https://github.com/candid82/joker/issues

Candid 2019-11-07T23:27:58.043800Z

How is this different from (joker.os/sh "bash" "-c" "jq ... | gron ... | less ...")? If you don't do anything with stdin/stdout and just want to pipe data through several tool it probably makes sense to use standard bash pipe functionality...

hlship 2019-11-07T01:35:13.040300Z

And I don't want to go overboard on reusable libraries or some kind of packaging system BUT it would be nice if, when a Joker script is executed, it was possible to require supporting libraries that were in the same directory as the script (after symbolic links are expanded). So my run-this-command and run-that-command joker scripts could share a few functions in a shared.joker file in the same directory. Something along those lines.

👍 1
sashton 2019-11-07T13:44:45.040900Z

This is already possible:

(ns orders
  (:require [lib.orders]
            [joker.tools.cli :as cli]))
(ns lib.orders)
<library functions>

sashton 2019-11-07T13:48:07.041200Z

Well, I guess lib.orders is under the lib directory, but based on the namespace, that is to be expected.

Candid 2019-11-07T23:15:20.043500Z

yes, this is already possible. More on this here: https://github.com/candid82/joker/blob/master/docs/misc/lib-loader.md

hlship 2019-11-07T23:45:37.044Z

That does work when using joker my-script.joke but doesn't when running my-script (that has #!/usr/bin/env joker).

hlship 2019-11-07T23:45:42.044200Z

Anything we can do for that case?

Candid 2019-11-08T00:54:13.044400Z

hm, there should not be any difference. I'll take a look.

Candid 2019-11-08T02:54:59.044600Z

I just checked and it works fine in both cases. Can you send me a zip of the project that's not working for you?

hlship 2019-11-08T17:06:54.047100Z

Ok, I'll double check that it's failing and put together a sample project.

hlship 2019-11-08T19:15:18.047300Z

I'm not sure why it seemed broken yesterday; user failure. I eventually found one minor case of failure, but it's not a big deal. https://github.com/candid82/joker/issues/291