Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read function from file, via -F? #87

Closed
dotemacs opened this issue Apr 4, 2021 · 3 comments
Closed

Read function from file, via -F? #87

dotemacs opened this issue Apr 4, 2021 · 3 comments

Comments

@dotemacs
Copy link
Contributor

dotemacs commented Apr 4, 2021

I went ahead and implemented a comparison of jq tutorial in jet:

https://gist.github.com/dotemacs/6c9185cca3cf59486b55471b1e965ed5

If you look at the last example:

https://gist.github.com/dotemacs/6c9185cca3cf59486b55471b1e965ed5#add-the-parent-commit-urls-to-the-above

writing that query at the shell prompt, without paren completion/matching, is quickly going to become cumbersome/error prone.

What do you think of the idea to add the switch -F (and something appropriate in long format e.g. --fn-from-file), which would read a function from file?

Why would you want to write a function in a file?

Arguably, your $EDITOR has probably the best support for paren matching/completion. So that way you can write the function in a file and the pass it in as a command line option e.g.

cat foo.json | jet -i json -o json -F /tmp/fn.clj

Just an idea, what do you think?

Thanks

@borkdude
Copy link
Owner

borkdude commented Apr 4, 2021

At this point you might just want to use babashka probably?

@borkdude
Copy link
Owner

borkdude commented Apr 4, 2021

@dotemacs I know a better solution: -f / --func accepts a file path as well. Just check if the expression happens to refer to an existing file, if not, execute it as a Clojure expression.

@dotemacs
Copy link
Contributor Author

dotemacs commented Apr 4, 2021

@dotemacs I know a better solution: -f / --func accepts a file path as well. Just check if the expression happens to refer to an existing file, if not, execute it as a Clojure expression.

Oh, I love that! :)

Added it, just let me think of a nice way to test. PR coming up shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants