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
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.
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?
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
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.
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.
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.
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).
Something like:
(let [result (os/pipe
[["jq" {:args ["-C" url]}]
["gron" {:args "-c"}]
["less"]])])
That would be so cool, IMO. Worth an issue (as I think your others are): https://github.com/candid82/joker/issues
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...
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.
This is already possible:
(ns orders
(:require [lib.orders]
[joker.tools.cli :as cli]))
(ns lib.orders)
<library functions>
Well, I guess lib.orders
is under the lib
directory, but based on the namespace, that is to be expected.
yes, this is already possible. More on this here: https://github.com/candid82/joker/blob/master/docs/misc/lib-loader.md
That does work when using joker my-script.joke
but doesn't when running my-script
(that has #!/usr/bin/env joker
).
Anything we can do for that case?
hm, there should not be any difference. I'll take a look.
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?
Ok, I'll double check that it's failing and put together a sample project.
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