Giter Site home page Giter Site logo

icr's Introduction

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

icr's People

Contributors

greyblake avatar jwoertink avatar veelenga avatar makenowjust avatar porcupine96 avatar oprypin avatar russolsen avatar mikemcquaid avatar jgillich avatar faustinoaq avatar puppetpies avatar anicholson avatar srcrip avatar brantou avatar sija avatar russ avatar marcosdsanchez avatar ktaragorn avatar jkthorne avatar icyleaf avatar coderhs avatar georgeu2000 avatar bfontaine avatar alexwayfer avatar yashko avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.