Exercism

The Exercism Command-Line Client

About the CLI

exercism is a command line tool to interact with exercism.io.

It is written in Go, but you do not need to install Go (or any other language) in order to use it.

Download the CLI

Download the latest release and place the binary in your PATH.

Installing with Homebrew

If you have homebrew installed, then you can install the CLI with the following command:

  $ brew install exercism

Arch User Repository (AUR)

The CLI is available via AUR.

Or... Use the Install Script

On Mac OS X or Linux, as a last resort, you can download the install script, and run it locally.

  $ curl -O https://raw.githubusercontent.com/exercism/cli-www/master/public/install
  $ chmod +x install
  $ ./install
  $ wget https://raw.githubusercontent.com/exercism/cli-www/master/public/install
  $ chmod +x install
  $ ./install

Please read the script before running it on your machine.

By default, the installer will try to put it in /usr/local/bin/ or $HOME/bin.

If you'd like it to live somewhere else, you can specify it up front:

  $ DIR=/path/to/bin ./install

Basic Usage

Configuration

You need to tell the tool who you are:

  $ exercism configure --key=YOUR_API_KEY

Visit exercism.io/account to get your api key.

By default, it will put exercism problems in ~/exercism. If you wish to override this, pass the --dir=/path/to/dir option to the configure command.

Your exercism API key can be found on your account page.

Downloading Exercises

You download exercises with the fetch command.

  $ exercism fetch

The first time you run the command, it will download the first exercise in each language. After that, it will download any exercises that you are currently working on, plus the next available exercise that you have not yet submitted any code to.

You can download a particular exercise in a given language by specifying the language and exercise to fetch:

  $ exercism fetch ruby food-chain

If you want to get the most recent test suite or README you can delete the old one and fetch the exercise again.

If you experience catastrophic data loss, you can restore all of your completed and current exercises:

  $ exercism restore

Submitting Exercises

To submit an exercise, use the submit command. If you solution has multiple files then submit them in a single command.

  $ exercism submit path/to/file1.ext path/to/file2.ext

You only need to submit the code you wrote to solve the exercise, not the test suite that you were given.

Extras

Bash completions

If you use a bash shell, you can use our CLI bash-completion script.

First download the script: [view source]

  $ mkdir -p ~/.config/exercism/
  $ curl http://cli.exercism.io/exercism_completion.bash > ~/.config/exercism/exercism_completion.bash

Load up the completion in your .bashrc, .bash_profile or .profile by adding the following snippet

  if [ -f ~/.config/exercism/exercism_completion.bash ]; then
    . ~/.config/exercism/exercism_completion.bash
  fi

Zsh completions

We also have a completion script for zsh.

First download the script: [view source]

  $ mkdir -p ~/.config/exercism/
  $ curl http://cli.exercism.io/exercism_completion.zsh > ~/.config/exercism/exercism_completion.zsh

Load up the completion in your .zshrc, .zsh_profile or .profile by adding the following snippet

  if [ -f ~/.config/exercism/exercism_completion.zsh ]; then
    . ~/.config/exercism/exercism_completion.zsh
  fi

If you are using the popular oh-my-zsh framework to manage your zsh plugins, you don't need to add the above snippet, all you need to do is create a file exercism_completion.zsh inside the ~/.oh-my-zsh/custom

Check

With either bash or zsh completion in place, you should be able to type

  exercism s

and autocomplete will give you

  exercism submit

Troubleshooting

Which version of the CLI are you using?

  $ exercism -v

If this is not the latest version, try upgrading.

If upgrading doesn't change the version, make sure that you are running the correct program (not the deprecated ruby gem):

  $ which exercism

If you have version 1.7.0 or greater, run the debug command and email the output to kytrinyx@exercism.io.

  $ exercism debug