• Stars
    star
    502
  • Rank 87,851 (Top 2 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactive console for Crystal programming language

ICR - Interactive Crystal Build Status

Interactive console for Crystal Programming Language.

Usage

It's like irb, but for Crystal:

GIF demo

Require local files

You can require local files by relative path (starts with ./):

require "./src/my_cool_lib"

Libs can also be required from the cli:

$ icr -r colorize -r ./src/my_cool_lib

Installation

Prerequisites:

  • The latest version of crystal.
  • Readline (for Debian/Ubuntu install libreadline6-dev package).
  • LLVM development files.

Clone the repo:

git clone https://github.com/crystal-community/icr.git

Switch to repo-directory:

cd icr

Build:

make

Install:

sudo make install

As a shard dependency

If you would like to include icr as a dependency, you can add it to your shard.yml

dependencies:
  icr:
    github: crystal-community/icr
    branch: master

Then just run shards install from your project!

Enjoy!

Arch Linux

Arch Linux users can install ICR from AUR.

How does it work?

  • Every time you press Enter it adds a new instruction, generates a new crystal program, and executes it.
  • The output is split into 2 parts: regular program output (e.g. output from puts 10) and the value returned by the last command.
  • The regular output is saved, and when you type a new instruction, a new program is generated. The saved output is subtracted from the new output, and the difference is printed out. It creates an illusion that only new instructions are executed :)

Commands and special locals

  • paste - enables paste mode
  • debug - toggles debug mode off and on. In debug mode icr will print the code before executing it
  • quit or exit - exits current interactive console
  • reset - clears out all of the accumulated commands
  • __ - holds the result of the last expression. Example:
icr > "5" + "2"
=> "52"
icr > __.to_i - 10
=> 42

Update check

ICR periodically checks for the new releases on Github. If your current version is out of date, it will simply show you a notice at start.

You can disable this behavior using --disable-update-check CLI flag.

Development

To run tests:

make test

Editor integration

  • inf-crystal.el - Connects REPL buffer to the ICR subprocess in Emacs

Contributors

  • greyblake Potapov Sergey - creator, maintainer
  • BlaXpirit Oleh Prypin - fixes for Crystal 0.16
  • puppetpies Brian Hood - support of records
  • jwoertink Jeremy Woertink - support of -r option and number of other contributions
  • veelenga V. Elenhaupt - maintenance
  • MakeNowJust TSUYUSATO Kitsune - syntax highlight support

More Repositories

1

crystal-patterns

📖 Examples of GOF patterns written in Crystal
Crystal
294
star
2

jwt

JWT implementation in Crystal
Crystal
205
star
3

crystal-libraries-needed

A list of libraries that are needed or wanted for the Crystal-Language
141
star
4

msgpack-crystal

MessagePack implementation in Crystal msgpack.org[Crystal]
Crystal
136
star
5

cossack

Simple and flexible HTTP client for Crystal with middleware and test support.
Crystal
106
star
6

hardware

Get CPU, Memory and Network informations of the running OS and its processes
Crystal
72
star
7

kiwi

A unified Crystal interface for key-value stores.
Crystal
64
star
8

toml.cr

TOML parser for Crystal
Crystal
60
star
9

zeromq-crystal

Crystal
48
star
10

crystal-ann

Web site to announce new Crystal projects, blog posts, updates and other work activities
CSS
45
star
11

leveldb

Crystal binding for LevelDB
Crystal
39
star
12

future.cr

Crystal
34
star
13

bloom_filter

Bloom filter implementation in Crystal lang
Crystal
34
star
14

timecop.cr

A testing library that allows "time travel," "freezing time," and "time acceleration". Inspired by the ruby-timecop library.
Crystal
19
star
15

crystal-kcov

Crystal
17
star
16

autolink.cr

🔗 Auto link for Crystal
Crystal
16
star
17

crystal-notifications

A library for notifications, this started as a port from ActiveSupport::Notifications
Crystal
16
star
18

bluetooth

Bluetooth Bluez binding in Crystal
Crystal
10
star
19

cr-config

An all-in-one configuration library to handle any possible configuration need
Crystal
10
star
20

community

The crystal community
10
star
21

snappy-crystal

Snappy bindings for Crystal
Crystal
6
star
22

cr-i18n

Crystal
3
star
23

kilt-components

Crystal
2
star