Welcome to codechef-cli’s documentation!

codechef-cli is a CLI (command line interface) to codechef.com.

codechef.com provides users the ability to practice and compete in competetive programming competetions.

Head over to the installation page to see how to install codechef cli.

If you are done installing, see quickstart for a quick guide.

See more detailed info about the commands in commmands documentation.

Installation

To install, first clone the github repository:

git clone https://github.com/vn-ki/codechef-cli.git

Next, run pip install on it:

pip install .

Development Installation

If you want to develop for codechef-cli, follow these instructions.

codechef-cli uses the pipenv workflow.

Start by installing pipenv.:

$ pip install pipenv

Clone the github repository and cd into it

git clone https://github.com/vn-ki/codechef-cli.git
cd codechef-cli

Install the dependencies,:

pipenv install

Happy developing.

Quickstart

You get a codechef command right out of the box.:

$ codechef
Usage: codechef [OPTIONS] COMMAND [ARGS]...

  Codechef CLI

Options:
  --version                       Show the version and exit.
  -ll, --log-level [ERROR|WARNING|INFO|DEBUG]
                                  Log Level
  --help                          Show this message and exit.

Commands:
  contest      Information about contests.
  login        Start the login process, receive tokens and store them
  submissions  Submit your solution to a problem and view it's status.

Use codechef login to login and authenticate the app. After that you can start using the different commands.

Commands

Contest

Contest command has the basic information about codechef contests. You can view contests, select one and see it’s problems.

You can see the ranklist of a contest after selecting one.

codechef contest command has three sub commands.

  • show
  • problems
  • rankings

First of all, you have to use show to see all the contests.

Show

show takes the following options:

Options:
  -cc, --contest-code CODE        The problem code of the problem you are
                                  submitting.
  --filter [past|present|future]  The contest code of the problem you are
                                  submitting.
  --help                          Show this message and exit.

Using filter you can filter through past, present or future contests.

When you execute codecehf show you are presented with a list of contests. You can select one by typing in the number of the contest.:

$ codechef contest show
+------+----------+-------------------------------------------------+---------------------+---------------------+
|    3 | ZCOPRAC  | ZCO Practice Contest                            | 2015-11-05 00:00:00 | 2020-01-05 00:00:00 |
|    2 | INOIPRAC | INOI Practice Contest                           | 2016-01-05 00:00:00 | 2020-01-05 00:00:00 |
|    1 | CAH1801  | CodeChef API Hackathon powered by Alibaba Cloud | 2018-08-27 21:15:00 | 2018-09-30 23:59:00 |
|------+----------+-------------------------------------------------+---------------------+---------------------|
|   No | code     | name                                            | startDate           | endDate             |
+------+----------+-------------------------------------------------+---------------------+---------------------+
Select one:

After selecting one of the contests, you con move on to other subcommands of contest, like ranklist to see the ranklist of the selected contest, or problems to see the problems of the selected contests.

Note

Only past contests have ranklist and problems. Use codechef contest --filter past to get them.

Problems

problems allow you to see the problems of the selected contest in a nice tui.

_images/problems.png

Problems of the contest presented in a nice TUI.

Rankings

rankings shows the ranklist of the selected contest.

Codechef Friends

Because, it’s always better with friends :)

NOTE: All endpoints can be tested using the nice interface provided by DRF. Just open them in your browser.

OAuth2

Root endpoint: /oauth

  • GET /redirect : redirect to codechef
  • GET /callback : handle response

API

Root endpoint: /api

  • GET /users/?q=<query> : Search/List users registered on “Codechef_friends”
  • GET /users/<username> : fetch user info from codechef
  • GET /friends* : returns user’s list of friends
  • PUT /friends* : add friend, requires:
    • Friends’ codechef id
  • DELETE /friends/<username>* : remove friend, requires:
    • Friends’ codechef id

* needs authentication header

Development

  • Rename .env.sample to .env and enter your own creds.

Server

  • pipenv install
  • ./manage.py runserver <port> to start server

Frontend

  • cd frontend && yarn && yarn serve to start frontend
  • Open /oauth/redirect to start flow, and recieve tokens
  • For production server, use the provided nginx config.

Demo