Crystal Run : shebang wrapper for Crystal
Crystal Run : shebang wrapper for Crystal
crun is a tool enabling one to put a “bang line” in the source code of
a Crystal program to run it, or to run such a source code file explicitly.
It was inspired by gorun and created in
an attempt to make experimenting with Crystal more appealing to people
used to Ruby and similar languages which operate most visibly with source
code.
As an example, copy the following content to a file named “hello.cr” (or
“hello”, if you prefer):
#!/usr/bin/env crun
puts "Hello world"
Then, simply run it:
$ chmod +x hello.cr
$ ./hello.cr
Hello world!
crun will:
$CRUN_CACHE_PATH
,$XDG_CACHE_HOME/crun
, ~/.cache/crun
, ~/.cache/.crun
or .crun
CLEAN_CACHE_DAYS
dependencies
of ashards.yml
file. Anchors used can be changed by settingsCRUN_SHARDS_START_ANCHOR
(default: ---
) andCRUN_SHARD_END_ANCHOR
(default: ...
).
#!/usr/bin/env crun
# ---
# minitest:
# github: ysbaddaden/minitest.cr
# ...
class Foo
def bar
"baz"
end
end
require "minitest/autorun"
class FooTest < Minitest::Test
def foo
@foo ||= Foo.new
end
def test_that_foo_bar_baz
assert_equal "baz", foo.bar
end
end
describe Foo do
let(:foo) { Foo.new }
describe "when asked about bar" do
it "must respond baz" do
foo.bar.must_equal("baz")
end
end
end
They are kept under $CRUN_CACHE_PATH
, $XDG_CACHE_HOME/crun
,~/.cache/crun
, ~/.cache/.crun
or .crun
in this order, in a directory
named after the hostname and the slug of the source file name.
You can remove these files, but there’s no reason to do this. These
compiled files will be garbage collected by crun itself after a while
once they stop being used. This is done in a fast and safe way so that
concurrently executing scripts will not fail to execute.
make release
make install
You can change PREFIX
or BINDIR
environment variable, see Makefile
usage: crun <source file> [...]
echo ':crystal:E::cr::/usr/local/bin/crun:OC' \
| sudo tee /proc/sys/fs/binfmt_misc/register
or
make binfmt
make githook
> make
targets:
auto Run tests suite continuously on writes
binfmt Add Linux binfmt support
check Run Ameba static code check
clean Remove crun builded binary
clobber Clean and remove editor backup files (*~)
crun Build crun binary
format Run Crystal format tool
githook Install Git pre-commit hook
help Show this help
install Install crun binary
release Build crun binary
spec Run crun specs
tests Run tests suite
todo Show fixme and todo comments
uninstall Uninstall crun binary
brew tap veelenga/tap
brew install ameba crystal fswatch imagemagick terminal-notifier
or
make osx
apt install -y -q inotify-tools libnotify-bin
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)