vishalagrawal's blog

By vishalagrawal, 20 months ago, In English

Command line tools can efficiently automate monotonous and repetitive tasks (such as creating source code files, copying boilerplate code, running code on sample testcases, etc.) and make competitive programming more fun.

There already exist various choices for command line tools in the competitive programming ecosystem like cpb and cf tool. The problem with these tools is they follow the "Flat File Structure" philosophy in which your source code and testcase files are kept in the same folder to improve the speed of manipulating (creating, updating, deleting) them. This approach causes a mess making it hard to navigate between source code files. As changes in testcase are rare, saving a few seconds is manipulating them might not be worth it.

cpb sample

CPPT is a cross-platform command-line tool made specifically to address this issue. It hides all the data required to test your code inside a hidden subfolder (.cppt) so that your folder remains clean and you can focus on writing your source code instead. It also provides you with easy-to-use and fast testcase manipulation commands.

cppt sample

Some of its key features are:-

  1. Fetch testcase data from an online judge.
  2. Compile (if applicable) and run source code against predefined or randomly generated testcases.
  3. Add testcases to run your code in advance or enter the testcase interactively.
  4. Create a source code file with your saved templates.
  5. Open the source code automatically in your favorite editor.

CPPT supports the following operating systems:-​

  1. Windows (both cmd and wsl)
  2. Linux
  3. MacOS

CPPT supports the following programming languages:-​

  1. C++
  2. Java
  3. Python

To get started, make sure you have python and pip on your system and the competitive companion extension on your browser.

Use the following command to install the tool.

$ pip install cppt

After installing the tool, type the command.

$ cppt

You should see the following help text.

Usage: cppt [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --help  Show this message and exit.

Commands:
  compile  compile source code
  config   get the location of config file or reset config file
  create   create a task
  fetch    retrieve testcase data from an online judge
  run      run code against testcases
  tc       commands related to testcase data
  test     brute force testing

For more info (with video demos) refer to the documentation.

PS: Thanks sarvjot for testing the tool for Windows (cmd and wsl).

  • Vote: I like it
  • +58
  • Vote: I do not like it

»
19 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I think there should be option to view the output file of last run for a particular testcase, to find the compilation errors etc.. Because doing cd into the metadata folder(.cppt) and doing a cat is just more time consuming.

Regarding rest of the functionality, the tool is good. (❁´◡`❁)