Command-Line Interface for BOJ
boj-cli
๋ฐฑ์ค ์จ๋ผ์ธ ์ ์ง ์ปค๋งจ๋๋ผ์ธ ์ธํฐํ์ด์ค.Table of contents
* Installation * Configuration * Usage * init * login * add * run * submit * accept * clean * open * random * case * Supported languages
Requirements
3.11 <= Python < 3.14MacOS,Linux,Windows
Installation
$ pip install boj-cli
# install from the source including dev dependencies.
$ pip install -e '.[dev]'
Configuration
# ~/myproject/.boj/config.yaml
general:
selenium_browser: "chrome" # required - firefox | chrome | edge
default_filetype: "cpp" # optional - default filetype for 'boj add'
editor_command: "nvim -o" # required - code | nvim | ..
workspace:
ongoing_dir: "problems" # optional - ongoing problem directory. default: ""
archive_dir: "archives" # optional - archive directory. default: "archives"
filetype:
py:
language: "python3" # required - language for your submission
main: "main.py" # required - the main file name
run: "python3 $file" # required - the run command
cpp:
language: "c++17"
main: "main.cpp"
source_templates: # optional - these files will be copied into source dir
- "main.cpp"
root_templates: # optional - these files will be copied into root dir
- "compile_flags.txt"
compile: "g++ -std=c++17 $file" # optional - set this option if you use compile language
run: "./a.out"
after: "rm -rf a.out" # optional - command to execute after 'boj run'
# other filetypes ..
filetype.language์ ๋ค์ด๊ฐ ์ ์๋ ๊ฐ๋ค์ Supported languages๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.
Usage
usage: boj [-h] [-v] {accept,ac,add,case,clean,init,open,random,run,submit} ...
positional arguments: {accept,ac,add,case,clean,init,open,random,run,submit} accept (ac) marks the given problem as accepted add sets up an environment of the given problem id case manages testcases clean archives accepted source files init initializes BOJ directory open opens a problem of given id in browser random queries and opens a random problem in browser run runs generated testcases submit submit your solution and trace the realtime statement
options: -h, --help show this help message and exit -v, --version show version
init
$ boj init
ํ์ฌ ๊ฒฝ๋ก๋ฅผ BOJ ๋๋ ํ ๋ฆฌ๋ก ์ค์ ํ๊ณ ๋ค์๊ณผ ๊ฐ์ ๋ฆฌ์์ค๋ค์ ์์ฑํฉ๋๋ค.
./.boj./.boj/config.yaml./.boj/templates
login
$ boj login
๋ฐฑ์ค ์จ๋ผ์ธ ์ ์ง์์๋ ๋ก๊ทธ์ธ ์ reCAPTCHA๋ฅผ ์ฌ์ฉํ๊ณ ์๊ธฐ ๋๋ฌธ์ ๋ก๊ทธ์ธ ๊ณผ์ ์ ์กฐ๊ธ ๋ฒ๊ฑฐ๋ก์ธ ์ ์์ต๋๋ค. ์ ๋ช
๋ น์ด๋ฅผ ์คํํ๋ฉด selenium ๋ธ๋ผ์ฐ์ ๊ฐ ์คํ๋๊ณ , reCAPTCHA๋ฅผ ํฌํจํ ๋ก๊ทธ์ธ์ ์ํํ๋ฉด ์ธ์
์ ๋ณด๋ฅผ ๋ก์ปฌ ๋๋ ํ ๋ฆฌ $HOME/.boj-cli์ ์ํธํํด์ ์ ์ฅํฉ๋๋ค.
๋ก๊ทธ์ธ ์ "๋ก๊ทธ์ธ ์ํ ์ ์ง" ์ฒดํฌ ๋ฐ์ค๋ฅผ ๋ฐ๋์ ์ ํํด์ฃผ์ธ์.
add
$ boj add 1234 -f cpp
Testcases have been created.
$ tree . โโโ 1234 โย ย โโโ compile_flags.txt โย ย โโโ main.cpp โย ย โโโ testcases โย ย โโโ 1 โย ย โย ย โโโ input.txt โย ย โย ย โโโ output.txt โย ย โโโ 2 โย ย โย ย โโโ input.txt โย ย โย ย โโโ output.txt โย ย โโโ 3 โย ย โย ย โโโ input.txt โย ย โย ย โโโ output.txt โย ย โโโ 4 โย ย โย ย โโโ input.txt โย ย โย ย โโโ output.txt โย ย โโโ 5 โย ย โโโ input.txt โย ย โโโ output.txt โโโ .boj โโโ config.yaml โโโ templates โโโ compile_flags.txt โโโ main.cpp
๋ฐฑ์ค ์จ๋ผ์ธ ์ ์ง ๋ฌธ์ ๋ฅผ ํ๊ธฐ์ํ ํด๋๋ฅผ ์์ฑํ๊ณ ๋ค์๊ณผ ๊ฐ์ ์์
๋ค์ ์ํํฉ๋๋ค. ./.boj/templatesํด๋์ ์์นํ ํ ํ๋ฆฟ ํ์ผ ๋ถ๋ฌ์ค๊ธฐ.- ํฌ๋กค๋ง์ ํ์ฉํด์ ํ ์คํธ๋ก ํ์ฑํ ํ ์คํธ์ผ์ด์ค ํ์ผ ์์ฑ.
--type, -t str: ํ์ผ ํ์
์ ์ง์ ํฉ๋๋ค. (e.g. cpp, ts, rs, py ...) (์ด ์ต์
์ 'config.general.default_filetype'์ override ํฉ๋๋ค.) --force, -f: ์ด๋ฏธ ๋ฌธ์ ๊ฐ ์กด์ฌํ๋ ๊ฒฝ์ฐ์๋ ๋ฎ์ด์๋๋ค.
run
# Outside of problem dir
$ boj run 1234
Inside of problem dir
$ cd 1234 && boj run
testcases ๊ฒฝ๋ก์ ์๋ ๋ชจ๋ ํ
์คํธ์ผ์ด์ค๋ฅผ ๋น๋๊ธฐ์ ์ผ๋ก ์คํํ๊ณ ์ ๋ต์ ๋น๊ตํฉ๋๋ค.
๋ฌธ์ ํด๋ ์์์ ์คํํ๋ฉด ๋ฌธ์ ๋ฒํธ ์ธ์๋ฅผ ์๋ตํ ์ ์์ต๋๋ค.
--timeout int(sec): ๊ฐ ํ
์คํธ์ผ์ด์ค์ ํ์์์์ ์ค์ ํฉ๋๋ค (default: 10์ด)
submit
# Outside of problem directory
$ boj submit 1234
Inside of problem directory
$ cd 1234 && boj submit
๋ก์ปฌ ์์ค ํ์ผ์ ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌํ๊ณ ๊ธฐ๋ณธ ๋ธ๋ผ์ฐ์ ์์ ์ ์ถ ํ๋ฉด์ผ๋ก ์ด๋ํฉ๋๋ค.
https://github.com/xvzc/boj-cli/issues/39 ๋ก ์ธํด ์ปค๋งจ๋๋ผ์ธ ์ ์ถ์ ๋์ด์ ๋์ํ์ง ์์ต๋๋ค.
ํด๋น ๋ช ๋ น์ด๋ฅผ ๋ฌธ์ ํด๋ ์์์ ์คํํ๋ฉด ๋ฌธ์ ๋ฒํธ ์ธ์๋ฅผ ์๋ตํ ์ ์์ต๋๋ค.
accept
# Outside of problem directory
$ boj accept 1234
Inside of problem directory
$ cd 1234 && boj ac
์ธ์๋ก ๋ฐ์ ๋ฌธ์ ๋ฅผ accepted ์ํ๋ก ๋ณ๊ฒฝํฉ๋๋ค.
accepted ์ฒ๋ฆฌ๋ ๋ฌธ์ ๋ boj clean ๋ช
๋ น์ด๋ก ์์นด์ด๋ธ ํ ์ ์์ต๋๋ค.
ํด๋น ๋ช ๋ น์ด๋ฅผ ๋ฌธ์ ํด๋ ์์์ ์คํํ๋ฉด ๋ฌธ์ ๋ฒํธ ์ธ์๋ฅผ ์๋ตํ ์ ์์ต๋๋ค.
-r, --revert when given, marks the problem as unaccepted
clean
$ boj clean
accepted๋ฅผ ๋ฐ์ ๋ชจ๋ ๋ฌธ์ ๋ค์ config.workspace.archive_dir๋ก ์์นด์ด๋ธํฉ๋๋ค.
์์นด์ด๋ธ ๋๋ ํ์ผ์ yyyymmddhhmmss{filename}์ ํฌ๋ฉง์ผ๋ก ์ ์ฅ๋ฉ๋๋ค.
๋ง์ง๋ง ์ ์ถ ์ดํ์ ๋ณ๊ฒฝ๋ ์์ค ์ฝ๋์ ๋ํด์๋ ์์นด์ด๋น์ ์ํํ์ง ์์ต๋๋ค.
--origin, -o: ์์นด์ด๋ธ ํ์ผ ํฌ๋ฉง์ ๋ฌด์ํ๊ณ ์๋ณธ ํ์ผ ์ด๋ฆ์ ์ฌ์ฉํ๋ฉฐ, ํ์ผ ์ด๋ฆ์ด ์ด๋ฏธ ์กด์ฌํ๋ฉด ๋ฎ์ด์๋๋ค.
open
# Outside of problem directory
$ boj open 1234
Inside of problem directory
$ cd 1234 && boj open
๊ธฐ๋ณธ ๋ธ๋ผ์ฐ์ ์์ ๋ฌธ์ ๋ฒํธ์ ํด๋นํ๋ ํ์ด์ง์ ๋งํฌ๋ก ์ด๋ํฉ๋๋ค.
๋ฌธ์ ํด๋ ์์์ ์คํํ๋ฉด ๋ฌธ์ ๋ฒํธ ์ธ์๋ฅผ ์๋ตํ ์ ์์ต๋๋ค.
random
$ boj random --tier g1..g5 --tags dp math
solvedac API๋ฅผ ํ์ฉํด์ ๋ฌธ์ ๋ฅผ ๊ฒ์ํ๊ณ , ๊ธฐ๋ณธ ๋ธ๋ผ์ฐ์ ์์ ๋งํฌ๋ก ์ด๋ํฉ๋๋ค.
์ฌ๋ฌ๊ฐ์ tags ์ต์ ์ 'OR' ์กฐ๊ฑด์ผ๋ก ๋์ํฉ๋๋ค.
'๋ด๊ฐ ํ์ง ์์ ๋ฌธ์ ' ๋ง ์ฟผ๋ฆฌ๋ฉ๋๋ค.
--tier, -i: ๋ฌธ์ ํฐ์ด ์ฟผ๋ฆฌ
--tags, -t: ๋ฌธ์ ํ๊ทธ ์ฟผ๋ฆฌ
case
$ boj case -e 1
$ boj case -n
config.general.editor_command ๊ฐ์ ์ฐธ์กฐํ์ฌ ํ
์คํธ ์ผ์ด์ค ํ์ผ์ ๊ด๋ฆฌํฉ๋๋ค.
--edit $TESTCASEID, -e $TESTACSEID: ์ฃผ์ด์ง id์ ํด๋นํ๋ ํ
์คํธ์ผ์ด์ค ํ์ผ๋ค์ ํธ์งํฉ๋๋ค.
--new, -n: ์๋ก์ด ํ
์คํธ์ผ์ด์ค๋ฅผ ์์ฑํ๊ณ ํธ์งํฉ๋๋ค. TESTCASE_ID๋ ์๋๋ถ์ฌ ๋ฉ๋๋ค.
Supported languages
c++17 python3 pypy3 c99 c11 text golfscript java8 c++98 ruby c++11 java11 kotlin(jvm) c++14 swift java8(openjdk) c++20 c# node.js go d rust2018 go(gccgo) c++17(clang) java15 d(ldc) php rust2015 pascal lua perl f# visual-basic objective-c c99(clang) c++98(clang) c++11(clang) c++14(clang) objective-c++ c11(clang) c90 c90(clang) c2x(clang) typescript c++20(clang) bash fortran scheme awk c2x assembly(32bit) assembly(64bit) o-caml whitespace lolcode intercal rhino cobol pike sed tcl brainf**k ada system-verilog algol68 befunge haxe ์ํฌ bc free-basic rust2021 scala