crystal-lang / shards

Dependency manager for the Crystal language
Other
758 stars 99 forks source link

Add run command #546

Closed luislavena closed 2 years ago

luislavena commented 2 years ago

Introduces shards run, similar to shards build, that builds and runs the specified target, providing a unified interface to developers.

With this, a developer can directly use shards run <target> in a single step without having first to compile (build) and then execute it with ./bin/target. No need for a script or wrapper.

This is inspired by crystal build and crystal run user experience (with the difference that crystal run creates a temporary binary).

This is very helpful for automatic rebuild scenarios, where a process is monitoring your code and can rebuild and relaunch your application.

When invoking shards run, it will first build the target (with the supplied options) and then invoke it, passing the extra options:

$ shards run myapp --stats -- --args

Is the same as:

$ shards build myapp --stats

$ ./bin/myapp --args

If the target exits with error, the exit code is passed back.

This builds on top of the great work done by @denolfe in #298 and aims to resolve #157 initial set of requests.

Sending this out for review and possible address the other points left out in the original PR.

Thank you. ❤️ ❤️ ❤️

luislavena commented 2 years ago

One note, if approved, I would like to squash all the changes into a single commit.

Thank you.