Skip to main content

boj-cli

백준 온라인 저지 커맨드라인 인터페이스.

Table of contents

Requirements

  • 3.11 <= Python < 3.14
  • MacOS, 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로 아카이브합니다.

아카이브 되는 파일은 yyyymmdd_hhmmss_{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 $TESTCASE_ID, -e $TESTACSE_ID: 주어진 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

Metadata

Release files for boj-cli 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boj-cli 1.3.0
File Size Uploaded Provenance Actions
boj_cli-1.3.0.tar.gz 32.3 kB Without provenance Details for boj_cli-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for boj-cli 1.3.0
File Interpreter ABI Platform Actions
boj_cli-1.3.0-py3-none-any.whl Python 3 none any Details for boj_cli-1.3.0-py3-none-any.whl

Total release size: 74.7 kB

Release files / boj_cli-1.3.0.tar.gz

Download URL boj_cli-1.3.0.tar.gz
Size 32.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8f0ace1b962e86a93847b183955a204003be0d8313afe808119dd23e5aeadaba
BLAKE2b-256 checksum
How to use checksums
e6daaacb5fccf59f85e3e591ce99a4cc05cdfb8275a00e8a2220acefa471a930
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / boj_cli-1.3.0-py3-none-any.whl

Download URL boj_cli-1.3.0-py3-none-any.whl
Size 42.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ff1835cb12a18d8eff1d7a97006ebb1f15b0383ca6e425b4f0108385babcb0f
BLAKE2b-256 checksum
How to use checksums
73c4d3054a797df1cb4420ab8d0e2f84a109b6178c16aebe6108087b792eccae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for boj-cli 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page