ACMOJ CLI is an unofficial command line interface utility designed to interact with the Shanghai Jiao Tong University (SJTU) ACM Online Judge (ACMOJ). It provides an easy and convenient way to perform problem submissions and track submission statuses from the command line, without needing to open your browser. The tool also allows you to manage source file templates with standardized comment sections containing metadata about the problem and author.
The main features of acmoj include:
- Seamless problem submission to the ACMOJ platform.
- Automatic login using stored session cookies.
- Create new source files with predefined templates.
- Track submission status in real-time.
- View the status of previous submissions without logging into the website.
Follow the steps below to get acmoj up and running on your terminal environment (Ubuntu/WSL):
Make sure the following dependencies are in place:
- Python 3.x
pip(Python's package installer)
Install any missing dependencies via the following commands:
sudo apt update
sudo apt install python3 python3-pipThe tool relies on the popular Python library requests to interact with the ACMOJ platform. Install it using pip:
pip install requestsgit clone https://github.com/stargazerZJ/ACMOJ-CLI.git ~/.config/acmojThis step ensures that you can call the acmoj command from anywhere in your terminal.
mkdir -p ~/.local/bin
ln -s ~/.config/acmoj/acmoj.py ~/.local/bin/acmoj
chmod +x ~/.local/bin/acmojEnsure that your terminal environment knows where to find the acmoj command. Add the following line to your ~/.bashrc (for bash users) or ~/.zshrc (for zsh users):
export PATH=$PATH:~/.local/binAfter editing the shell configuration file (~/.bashrc or ~/.zshrc), apply the changes:
source ~/.bashrc # for bash users
# OR
source ~/.zshrc # for zsh usersTo check if the installation was successful, run:
acmoj -hIf the installation was successful, you should see the help message for the acmoj command.
Congratulations! You've successfully installed acmoj on your system. 🎉
The tool provides several CLI subcommands, mostly tied to typical workflows like logging in, submitting code, and tracking submissions.
Open the terminal and call acmoj with these various commands:
You need to log in before making submissions.
acmoj login -u <your_username>- You will be prompted to enter your
password. - This stores a login cookie locally, meaning you won't have to log in every time.
To quickly generate a new source file for a problem:
acmoj new <problem_id>- The command creates a new
.cppfile with metadata (such asProblem ID,Date,Author). - Optionally, you can specify an algorithm tag with the flag
-ato categorize your solution better.
Example:
acmoj new 12345 -a "Dynamic Programming"Submit your solution by specifying the file path and problem ID.
acmoj submit <source_path> -p <problem_id>- You can omit
-p problem_idif the problem ID is already present within the source file's pre-filled comments. - To track your submission status in real time, use the flag
-t:
acmoj submit <source_path> -p <problem_id> -tTo check the status of the most recent submission:
acmoj statusProvide the submission ID explicitly if you want to see a past submission's status:
acmoj status <submission_id>For more information on the available commands and their usage, run:
acmoj -hTo get help on a specific command, use:
acmoj <command> -hExample:
acmoj submit -hYou can personalize the tool to suit your preferences by editing certain relevant parts like the author name or the code templates.
Author information is included in the source file's metadata. By default, the author name is set to You ([email protected]).
To change the author globally, you can set the environment variable in your .bashrc or .zshrc file:
Edit your .bashrc or .zshrc file (for bash and zsh users respectively):
nano ~/.bashrc # If you use Bash
nano ~/.zshrc # If you use ZSHAdd the following line at the end:
export ACMOJ_AUTHOR="Your Name ([email protected])"Then, reload your shell configuration:
source ~/.bashrc # Bash
source ~/.zshrc # ZSHThe templates help you ensure a consistent structure for all of your submissions.
The template is stored at:
~/.config/acmoj/template.cppYou can customize the template file to fit your own coding style:
nano ~/.config/acmoj/template.cppFor example, a simple template.cpp could look like this:
#include<bits/stdc++.h>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}This will be automatically filled into the new problem file whenever you run acmoj new.
Now you're ready to start using ACMOJ CLI! If you have any issues or suggestions, feel free to open an issue on the GitHub repository. Happy coding and good luck with your competitions! 🎉