diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 09da2b8..ef14aad --- a/.gitignore +++ b/.gitignore @@ -138,5 +138,10 @@ dmypy.json # pytype static type analyzer .pytype/ +*.pyc + +# jetbrains pycharm +.idea/ + # End of https://www.toptal.com/developers/gitignore/api/python n \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 53a1665..bf2cf19 --- a/README.md +++ b/README.md @@ -1,64 +1,267 @@ # oj-cli ## Installation -### Ghost Server +### Installation in NCCU GHOST + ``` -cd ~ -echo 'export PATH="~f103207425/.local/bin:$PATH"' >> ~/.profile -source ~/.bashrc +echo 'alias oj="python2.7 ~s10940/oj-cli/oj.py"' >> ~/.profile +source ~/.profile ``` -### Install from Source Code -1. Clone this project +### Installation from source code + ``` -git clone https://github.com/josix/oj-cli.git +git clone https://github.com/andyjjrt/oj-cli.git +cd oj-cli +echo "alias oj='python2.7 $PWD/oj'" >> ~/.bashrc +source ~/.bashrc ``` -2. Update `HOST` variable value in file `oj-cli/constants.py` to the OnlineJudge URL you accessing -3. Update Shebang(`#!/opt/csw/bin/python2.7`) value to a suitable one in `oj.py` +If your shell is different like `ash`, you may need to change `.bashrc` to `.profile`. +After installation, please modify `CONTEST_NAME` variable in `constants.py` to the target contest name. + ### Commands -### `oj login` -### About +### oj login +#### About Use `oj login` to login to the account in OnlineJudge. It required you to enter your account information so that `oj-cli` could access OnlineJudge service successfully. After entering your username and password. `oj-cli` will respond if you login successfully or not. -### Usage +#### Usage No argument required. Only enter `oj login` and fill the account information to login to OnlineJudge. -### Example +#### Example ``` $ oj login Usernme: Password: ``` -### `oj get_assign ` -### About -Use `oj get_assign ` to download the latest assignment from contest. The downloaded files are stored in folder `hwX` or `exX`. The folder includes testing data, output data, and template C script, which are named as `1.in`, `1.out`, and `hwX.c`(or `exX.c`) separately. -### Usage -`oj get_assign` only required one argument to execute. -#### assign_no -assign_no represents your assign number like `hw1`, `ex1`, etc. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number has not opened. +### oj get +#### About +Use `oj get ` to download the latest assignment from contest. The downloaded files are stored in folder `hwX`. The folder includes testing data, output data, and template C script, which are named as `1.in`, `1.out`, and `main.c` separately. +#### Usage +`oj get` only required one argument to execute. +##### assign_no +assign_no represents your assign number like `hw1`, `hw2` according to your updates. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number has not opened and give valid assign numbers. -### Example +#### Example ``` -$ oj get_assign hw2 -$ oj get_assign ex3 +$ oj get hw1 +Made a [hw1] folder in your current directory. ``` +### oj get_p +#### About +Use `oj get_p ` to download the problem in problem list. The downloaded files are stored in folder `problem_X`. The folder includes testing data, output data, and template C script, which are named as `1.in`, `1.out`, and `main.c` separately. +#### Usage +`oj get_p` only required one argument to execute. +##### problem_no +problem_no represents your problem display id like `1`, `57-2` according to your updates. `oj-cli` will prompt `Invalid Problem Id!` if the input problem id is invalid. +##### Notice +problem_no somtimes has blanks, cli will automatically replace them. +#### Example +``` +$ oj get_p 57-2 +Made a [problem_57-2] folder in your current directory. +``` -### `oj submit ` -### About -Use `oj submit ` to submit your code to contest. +### oj submit +#### About +Use `oj submit ` to submit your code to contest and return the results. -### Usage -`oj get_assign` required two arguments to execute. +#### Usage +`oj submit` required two arguments to execute. -#### assign_no -assign_no represents your assign number like `hw1`, `ex1`, etc. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number has not opened. +##### assign_no +assign_no represents your assign number like `hw1`, `hw2` according to your updates. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number has not opened and give valid assign numbers. -#### code_file +##### code_file code_file is the path to your script. `oj` will read the file then submit this answer to OnlineJudge Service. #### Example ``` $ oj submit hw2 hw2.c -$ oj submit ex3 ../ex3.c +Submit successfully! +Getting submission status... +================================================= +Result: AC(Accept) Score: 100 +|ID |Status | Time| Mem| Score| +|#1 |AC(Accept) | 0ms| 2MB| 20| +|#2 |AC(Accept) | 2ms| 2MB| 20| +|#3 |AC(Accept) | 40ms| 2MB| 20| +|#4 |AC(Accept) | 75ms| 2MB| 20| +|#5 |AC(Accept) | 5ms| 2MB| 20| +================================================= +``` + + +### oj submit_p +#### About +Use `oj submit_p ` to submit your code to problem and return the results. + +#### Usage +`oj submit_p` required three arguments to execute. + +##### problem_no +assign_no represents your assign number like `1`, `2` according to your updates. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number soes not exist. + +Notice that blanks in `problem_no` will be replaced by nothing. + +##### code_file +code_file is the path to your script. `oj` will read the file then submit this answer to OnlineJudge Service. + +#### Example +``` +$ oj problem_submit 1091CP1_Exercise8 ex8.c +Submit successfully!! +Getting submission status... +======================================================== +Result: AC(Accept) Score: 100 +|ID |Status | Time| Mem| Score| +|#1 |AC(Accept) | 1ms| 2MB| 20| +|#2 |AC(Accept) | 1ms| 2MB| 20| +|#3 |AC(Accept) | 1ms| 2MB| 20| +|#4 |AC(Accept) | 2ms| 2MB| 20| +|#5 |AC(Accept) | 1ms| 2MB| 20| +======================================================== + +``` + + +### oj rank +#### About +Use `oj rank ` to view the class result of this assign. +#### Usage +`oj rank` only required one argument to execute. +#### assign_no +assign_no represents your assign number like `hw1`, `hw2` according to your updates. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number has not opened and give valid assign numbers. + +#### Example +``` +$ oj rank hw2 +Your status of hw2 : AC(Accept) +================================================ + 1~ 10 : 0 | AC(Accept) : 8 + 11~ 20 : 0 | RE(Runtime Error) : 29 + 21~ 30 : 0 | PAC(Partial Accepted) : 54 + 31~ 40 : 1 | WA(Wrong Answer) : 81 + 41~ 50 : 0 | CE(Compilation Error) : 10 + 51~ 60 : 0 |-------------------------------- + 61~ 70 : 0 | Total submissions : 182 + 71~ 80 : 0 | + 81~ 90 : 0 | + 91~100 : 12 | +================================================ +For real score ranking,please go to the website. ``` + + +### oj update +#### About +Use `oj update` to get the latest assignments. +#### Usage +No argument required. Only enter `oj update` and it will automatically get the assignments. + +#### Example +``` +$ oj update +Target Contest: 1101CP1 +Found HomeWork: hw0 [Online Submission] +``` + +### oj update_p +#### About +Use `oj update_p` to get the latest assignments. +#### Usage +No argument required. Only enter `oj update_p` and it will automatically get the problems. + +#### Example +``` +$ oj update_p +Updated problems successfully! +``` + + +### oj status +#### About +Use `oj status ` to view the latest 20 submissions of this contest. +#### Usage +`oj status` only required one argument to execute. +##### assign_no +assign_no represents your assign number like `hw1`, `hw2` according to your updates. `oj-cli` will prompt `Invalid Assign Number!` if the input assign number has not opened and give valid assign numbers. + +#### Example +``` +$ oj status hw2 +============================================================================ +| Contest Name: hw2 | +============================================================================ +|User |Status | Time| Mem| When| +|108xxxxxx |WA(Wrong Answer) | 0ms| 2MB|2020-12-18 10:31:12| +|109xxxxxx |AC(Accept) | 0ms| 2MB|2020-12-18 10:07:14| +|109xxxxxx |PAC(Partial Accepted) | 0ms| 2MB|2020-12-18 09:20:10| +|109xxxxxx |PAC(Partial Accepted) | 21ms| 2MB|2020-12-18 09:20:02| +|109xxxxxx |PAC(Partial Accepted) | 17ms| 2MB|2020-12-18 09:07:19| +|109xxxxxx |PAC(Partial Accepted) | 1ms| 4MB|2020-12-18 08:50:13| +============================================================================ +... +``` + +### oj mystat