1. Crystal CLI

  • get cli help

$ crystal -h
  • generate a new app:

$ crystal init app project_name
$ cd project_name
  • compile and run (while developing):

$ crystal run src/code.cr
  • compile to executable and run:

$ crystal build src/file.cr
$ ./file
  • compile and optimize build (for release into the wild):

$ crystal build --release src/file.cr -o new_name
$ ./new_name
crystal build -Dpreview_mt code.cr -o code
$ ./code                   # defaul is 4 workers
$ CRYSTAL_WORKERS=2 ./code # uses two CPUS
$ CRYSTAL_WORKERS=4 ./code # same as default
  • compile and run (all) specs:

$ crystal spec
  • build docs from code comments

$ crystal docs