Crystal Play Command

You can run a local instance of Crystal playground to run code on the browser.

Run crystal play and visit localhost:8080 on your browser.

The Playground

In the playground, you can write your code on the left-hand side and the code will automatically (800ms delay by default) compile, producing line-by-line results and type information.

The Workbook

At the root of your project (where you ran crystal play) you can create a directory named playground. All the Markdown and Crystal files in this directory will be listed at localhost:8080/workbook. On this page, you'll be able to interact with code snippets that are fenced as playground in Markdown files. You can also view and interact with .cr files.

Notes:

  1. I had to install libssl-dev and libz-dev packages for crystal play to work.
  2. Tagging code fences as "playground" instead of Crystal is not a great solution. There might be a workaround.