boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 180 forks source link

New task: call #597

Closed pesterhazy closed 7 years ago

pesterhazy commented 7 years ago

This task can be used for ad-hoc code, either from the command line or from build.boot. Use cases:

As used from build.boot, the call task has the advantage that new users don't need to learn about with-pass-thru to execute project code.

The --eval option allows to execute an arbitrary Clojure from. It is similar to boot's --init but can be run as part of a boot pipeline.

pesterhazy commented 7 years ago

@arichiardi, I've amended the docstring for --once

Yes, it is intentional that you can call multiple functions or pieces of code and even mix both, e.g.

boot call --print --function clojure-version --function all-ns --eval "(+ 3 4)" --eval "(- 1 5)"

Evals are executed after function calls.

RadicalZephyr commented 7 years ago

I really like this task. One thing I would advocate for as well would be an option to call it in the pre section of the task or in the post section.

I recently created a simple task allowing me to do that and used it in a project of mine to stop my custom application system before running the build and refreshing the code. Then as the post portion of the same task (i.e. after all those other tasks have successfully run), I restart my system with another function call.

So, either another task call-after that is nearly identical, or (my preference) options for this task to call the same types of things in the post portion of the task.

kommen commented 7 years ago

This task would solve an issue I had recently with starting nodejs for a ClojureScript build target with watch, where I then had write my own task using delay with with-pass-truh to only start node once after after the initial compile.

pesterhazy commented 7 years ago

@kommen, your suggestion sounds good, I actually debated whether to add this to the initial pr. I'll add a --post flag when I'm back from vacation.

pesterhazy commented 7 years ago

Sorry the last comment was directed at @radicalzephyr

pesterhazy commented 7 years ago

As suggested by @RadicalZephyr, I've updated the PR to include a --post flag.

alandipert commented 7 years ago

I like it. Can you please add to CHANGES.md? Thanks!

pesterhazy commented 7 years ago

@alandipert I've added the changelog entry and squashed the commits