'mango' is a Command Line Interface(CLI) based task parser and tester for popular online judge 'Codeforces'. It supports the regular contest and gym. All of the functionalities of this CLI works for only C++ language.
Head over to the release page to download the latest mango that is compatible with your system and os.
We have to setup the mango
globally so that we can run commands from anywhere through the Command Prompt or Terminal.
Windows:
- Keep 'mango.exe' in any folder you prefer
- Add the folder path from step 1 to System Variable Path. (How to add path in System Var? See here: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/)
- Open Command Prompt and run
mango version
to test if everything works fine.
Mac:
- Keep 'mango' executable file at
/usr/local/bin
folder - Change the permission of the file by
chmod +x mango
command. - Open Terminal and run
mango version
to test if everything works fine.
Linux:
May be similar to mac. Didn't try in linux.
- Set default programs(like Sublime Text, VS Code, Code Blocks etc.) to open .cpp & .json files. (How to change default programs in windows? See here: https://www.digitaltrends.com/computing/how-to-change-file-associations/)
- Open command prompt and run 'mango configure'. It will open config.json file. Or in windows, go to AppData>Roaming>mango, you'll find the config.json file there. Now configure as you prefer. But DO NOT CHANGE the OJ and Host property. The config.json file looks like the following..
{
"Workspace": "C:/Users/SkMonir/Desktop/Contest",
"CompilationCommand": "g++",
"CompilationArgs": "-std=c++17",
"CurrentContestId": "1520",
"OJ": "codeforces",
"Host": "https://codeforces.com",
"TemplatePath": "C:/Users/SkMonir/Desktop/Contest/template.cpp",
"Author": "skmonir"
}
- Set 'Workspace' as the full path of the folder where all of the contest sources and testcases will be stored
- Set 'TemplatePath' as the full path of your template file. If you ommit TemplatePath, a default template will be created for the source file.
- Set 'Author' as your username/handle or anything name you prefer. It will be used in your template.
- We don't necessarily need to set 'CurrentContestId' from here. See the Available Commands section to know how it is set.
- Enjoy!
NOTE: DO NOT USE any variable as configuration value. For example, do not use
~/contest
, rather use/home/user/contest
for directory path.
workspace
├── codeforces
│ └── 1521
│ ├── src
│ │ ├── A.cpp
│ │ ├── B.cpp
│ │ │
│ │ │
│ │ └── E.cpp
│ ├── testcase
│ │ ├── A.json
│ │ ├── B.json
│ │ │
│ │ │
│ │ └── E.json
mango <command> <argument>
=> Only configure
, version
and help
commands don't need any argument.
=> For other comamnds, the argument format is <contest_id><problem_id>
. But both <contest_id>
and <problem_id>
are optional for corresponding command.
All of the commands can be run from Command Prompt or Terminal.
-
mango setc 1521
: sets current working contest ID -
mango configure
: opens the config.json file to update & save configuration -
mango parse 1521
: command 1 + parses samples of all the problems for specified contest ID -
mango parse 1521A
: command 1 + parses samples of Problem A for specified contest ID -
mango source 1521A
: creates source file of Problem A for specified contest ID -
mango source A
: creates source file of Problem A for current working contest ID -
mango open 1521
: opens all the source files in the default editor for specified contest ID -
mango open 1521A
: opens source file of Problem A in the default editor for specified contest ID -
mango open A
: opens source file of Problem A in the default editor for current working contest ID -
mango create 1521
: combination of commands (1, 3, 7) for specified contest ID -
mango create 1521A
: combination of commands (1, 4, 6, 8) for Problem A -
mango compile 1521A
: compiles source file of Problem A for specified contest ID -
mango compile A
: compiles source file of Problem A for current working contest ID -
mango test 1521A
: command 12 + tests Problem A for specified contest ID -
mango test A
: command 13 + tests Problem A for current working contest ID -
mango version
: shows the current mango version -
mango help
: shows help docs
NOTE: The source and testcase filenames are CASE SENSITIVE in Mac and Linux. The filenames are parsed from Codeforces problem name labels(such as A, B, F1, F2 etc.). So BE CAREFULL when using the problem ID in commands, it should be as same as the filename.
Apart from running our program in command prompt in windows, we can also directly test our program from Sublime Text through the custom build system. To configure the sublime build system in Windows, please follow the instructions below..
- From Sublime Text menubar, go to
Tools > Build System > New Build System
. It will open a file. - Delete the content from the file and copy & paste the following code.
{
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.cc, source.c++, source.cpp",
"variants":
[
{
"name": "RunOnCmdPrompt",
"shell_cmd": "g++ -O2 -static -std=gnu++17 \"${file}\" -o \"${file_base_name}\" && start cmd /k \"${file_base_name} & pause & exit\""
},
{
"name": "RunOnMangoTester",
"shell_cmd": "start cmd /k mango test \"${file_base_name}\" & pause & exit\""
}
]
}
- Press Ctrl+S to save the file. Give it a name like
cpp_custom_build.sublime-build
and save. - Go to
Tools > Build System
. We will find our custom build name(i.ecpp_custom_build
) in the list. Select the build name. - Now create a problem or contest by 'mango create' command and write the code.
- To test our code from mango, we have to select our build variant only for once. Go to
Tools > Build With
(Shortcut CtrlShiftB), a pop-up will appear on top-center of the screen. Selectcpp_custom_build - RunOnMangoTester
from the pop-up. Now for every test, just go toTools > Build
and a console will open with the test result. - To run our program from Command Prompt for custom testing, we need to change our build variant like the previous step. But in this case we will select
cpp_custom_build - RunOnCmdPrompt
from the pop-up. Now go toTools > Build
to run the program and it will open a console where we can give input and see output for the program.