Fork me on GitHub
#joker
<
2019-11-07
>
hlship01:11:22

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

👍 4
jcburley13:11:18

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.

jcburley13:11:18

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?

hlship01:11:58

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

👍 4
jcburley16:11:52

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.

jcburley17:11:53

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.

jcburley17:11:49

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.

hlship01:11:43

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).

👍 4
hlship01:11:19

Something like:

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

👍 4
jcburley13:11:13

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

Candid23:11:58

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...

hlship01:11:13

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.

👍 4
sashton13:11:45

This is already possible:

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

sashton13:11:07

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

hlship23:11:37

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

hlship23:11:42

Anything we can do for that case?

Candid00:11:13

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

Candid02:11:59

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?

hlship17:11:54

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

hlship19:11:18

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