Skip to main content

Configuration

Creating Your First Configuration File#

Execute the following command to create a configuration file:

cpbooster init

This command will create a file called cpbooster-config.json in your $HOME directory with default values. If you wish to create your configuration file somewhere else you can specify the path using --configPath flag each time you run a command.

tip

By default cpbooster looks for the configuration file in any of the following directories

  1. $HOME/cpbooster-config.json
  2. $HOME/.cpbooster/cpbooster-config.json
  3. $HOME/.config/cpbooster/cpbooster-config.json

Take a look at this issue for context.

Configuration File Example#

cpbooster-config.json#

{
"contestsDirectory": "/home/user/Contests",
"port": 1327,
"editor": "konsole",
"closeAfterClone": false,
"showStatusPageOnSubmit": true,
"useUserDefaultBrowser": true,
"preferredLang": "cpp",
"hideTestCaseInput": false,
"cloneInCurrentDir": false,
"languages": {
"cpp": {
"template": "template.cpp",
"command": "g++ -std=gnu++17 -O2",
"debugCommand": "g++ -std=gnu++17 -DDEBUG -Wshadow -Wall",
"aliases": {
"codeforces": "54",
"atcoder": "4003",
"omegaup": "cpp17-gcc"
},
"type": "compiled",
"commentString": "//"
},
"py": {
"template": "template.py",
"command": "python3",
"debugCommand": "python3 -O",
"aliases": {
"codeforces": "31",
"atcoder": "4006",
"omegaup": "py3"
},
"type": "interpreted",
"commentString": "#"
},
"java": {
"template": "",
"command": "javac",
"debugCommand": "javac",
"runCommand": "java",
"aliases": {
"codeforces": "36",
"atcoder": "4005",
"omegaup": "java"
},
"type": "mixed",
"commentString": "//"
}
}
}

Fields Description#

contestsDirectory: string#

The path to the directory where contests folders will be created when you run cpb clone.

The directory of a user that has cloned 3 contests would look like this:

$ cd path/to/contests/directory
$ tree -L 1
.
โ”œโ”€โ”€ AtCoder-AtCoderBeginnerContest194
โ”œโ”€โ”€ AtCoder-AtCoderRegularContest113
โ””โ”€โ”€ Codeforces-CodeforcesRound665Div.2

port: number#

Specifies the port where competitive companion extension will send problem's data. 1327 is the default port for cpbooster in competitive companion so, if you don't change the port, it will just work as expected. If you must change it, then be sure that you also change it in competitive companion extension settings.

editor: string#

Name of the editor that will be opened after running cpb clone. The editor value should match with the terminal command you use to launch it. See Editor Requirements

note

An editor can be a terminal emulator also.

Editor Requirements#

  1. You must be able to open your editor using a terminal command.
  2. If the editor is a terminal emulator it should be in the list of supported terminals.
  3. If the editor is NOT a terminal emulator. The editor command should support the following format to open a directory:
$ editor [directory]

If your editor does not support this format but has another way to open a directory, you could take a look at "How to add an editor"

Examples#

  • Using regular editor ( VSCode ):
{
"editor": "code"
}

since code is the command that is used to execute vscode from the terminal.

  • Using terminal emulator ( konsole ):
{
"editor": "konsole"
}
note

Terminal Emulator support is currently limited to this List of supported terminals. Visit the section "How to add an editor" if you wish to contribute and add support for other terminal emulators.

List of supported terminals#

  • "konsole"
  • "xterm"
  • "gnome-terminal"
  • "deepin-terminal"
  • "kitty"
  • "alacritty"
  • "terminal" (MacOS)

closeAfterClone: boolean#

Whether to close the terminal after the execution of cpb clone or not.

caution

When using this option as true verify that your editor satisfies the Editor Requirements, otherwise, you might end up with your terminal closed and no editor opened.

showStatusPageOnSubmit: boolean#

Whether to open a browser window in the submission status page or not, after running cpb submit

useUserDefaultBrowser: boolean#

Whether to open the status page using default browser or the one bundled with cpbooster. See Submit Requirements

preferredLang: string#

The extension name in lowercase of your preferred language. ( i.e. "cpp", "py", "java", ... ), cpb clone uses this value to create corresponding source files with the template of your preferred language.

important

This value must match exactly (case-sensitive) with the extension used in the source files.

hideTestCaseInput: boolean#

Whether or not to show the test case input when testing

cloneInCurrentDir: boolean#

When true it clones contests or single problems in current directory instead of the global contest directory.

languages: Record<LangExtension, LangConfig>#

In languages you can configure the settings of each programming language.

note

cpbooster officially supports the following languages:

  • c
  • c++
  • rust
  • go
  • python
  • javascript
  • ruby
  • java
  • kotlin
  • scala

officially supporting these languages means that they were tested exhaustively, however, other languages might be supported as well due to the generality of the algorithm used to parse the commands to compile or run. In case cpbooster can't work correctly with the language you wish to use, visit the section "How to add a language" which will guide you on how to contribute to the project.

important

The keys (<lang>) must match exactly (case-sensitive) with the extension used in the source files. i.e. if you use cpp extension for your c++ programs then you must use cpp as key of the json object, CPP won't work, neither Cpp nor cPP, ... and the same applies for the languages

languages.<lang>.template: string#

Path to your competitive programming template for the corresponding <lang>.

Here are some examples of competitive programming templates (if you wish, you can download them and use them):

languages.<lang>.command: string#

The command that will be used to compile (compiled or mixed languages) or run (interpreted languages) your program for testing purposes.

For example: If you use codeforces it is convenient that you use the same command they use for each language

{
"languages": {
"cpp": {
"command": "g++ -std=gnu++17 -O2"
},
"py": {
"command": "python3"
}
}
}
tip

If you specify the name of the executable file in this command, it will be used instead of the default name (same as source file). See Test section.

Example: In C++ you can use the -o flag to specify the name of the executable file that will be created after compilation.

{
"languages": {
"cpp": {
"command": "g++ -std=gnu++17 -o executableName.exe"
}
}
}

languages.<lang>.debugCommand: string#

The command that will be used to compile (compiled or mixed languages) or run (interpreted languages) your program for debugging purposes. Usually debugCommand has more flags than command.

Some debug command examples for cpp and py:

{
"languages": {
"cpp": {
"command": "g++ -std=gnu++17 -O2",
"debugCommand": "g++ -std=gnu++17 -O3 -DDEBUG -Wshadow -Wall"
},
"py": {
"command": "python3",
"debugCommand": "python3 -O"
}
}
}
tip

You can specify the name of the executable file in the same way you would do it in languages.<lang>.command.

Visit the Debug section to see usage examples of this feature.

languages.<lang>.runCommand: string#

The command that will be used to run mixed type languages like (java, kotlin, scala, ...).

note

This type of languages are compiled with some command (i.e. javac, kotlinc, scalac, ...) but they get run with a different one (java, kotlin, scala, ...)

languages.<lang>.aliases: Object<OnlineJudgeName, string>#

Language "aliases" for each OnlineJudge. See How To Configure Language Aliases.

For example: the alias for C++ in Codeforces and AtCoder is "54" and "4006" respectively

{
"languages": {
"cpp": {
"aliases": {
"codeforces": "54",
"atcoder": "4006"
}
}
}
}

languages.<lang>.type: "compiled" | "interpreted" | "mixed"#

Specifies whether the language is "compiled" (C++, go, rust, C#), "interpreted" (python, javascript, ruby, ...) or "mixed" (java, kotlin, scala, ...). cpbooster is aware that some languages can be interpreted as well as compiled, like python which can be compiled with nuitka or javascript which can be compiled with nectarjs. With this option you have the chance to tell cpbooster how to work with the language you provide. For a definition of mixed languages, See Mixed Languages

note

In case this option is not provided, then cpbooster will try to infer the type depending on the language. But consider that cpbooster is not aware of all the languages it actually support, specifying this option reduces the risk of unexpected errors. See Languages Support

languages.<lang>.commentString: string#

Tells cpbooster which comment string to use depending on the language. cpbooster uses a generic algorithm to support a great variety of languages, some of them are know by cpbooster but some others are unknown for it, therefore cpbooster might not know how to write comments in that language.

note

Comments are used to write information in the source code file such as:

  • time-limit
  • problem-url