This is a command line tool for Codeforces.
There are two modes available: interactive and non-interactive mode.
To use in interactive mode:
$ codeforces
> <command> [command args]
in non-interactive mode:
$ codeforces <command> [command args]
use exit
to exit in interactive mode.
Current supported commands are:
Usage: login
This command only available in non-interactive mode. Input your handle and password when it prompts.
Usage: submit </path/to/file> [--watch] [--contest <contest_id>/--gym <gym_id>/--mashup <mashup_id>]
Now only support cpp files, and default to use C++11.
Now you can run set init
to setup default complier based on file extensions. More information, see Supports and set.
If watch
option is provided, a real-time update will active until verdict reveal. Update rate depend on network speed. If this field is empty, the submission id will be printed.
One can add --contest
options to specify which contest will be submitted to. The priority of this option is higher than file name described below. Same as --gym
and --mashup
.
Notice that if this command are run in interactive mode, you have to login in non-interactive mode first. In case of non-interactive mode, you can login at same time when you submit.
File should be named as problem.ext
. For example, 977D.cpp
is a C++ solution for problem 977D
, and this is not case sensitive.
If --contest
(or another two options) are provided, file can be named as *index.ext
. That is, meowF.cpp
will be send to problem F of the specified contest.
Usage: set <init/cookie/compiler> [compiler options]
Only set cookie
are available in interactive mode. Others are only available in non-interactive mode.
Directory ~/.codeforces-cli-tool
must exist when execute this command except set init
.
Run set init
at after install this package and follow the instruction to setup. Unless you are sure to refresh both cookie and compiler, do not run init
after first time using it. This package will use ~/.codeforces-cli-tool
to store some file.
The only way to logout from Codeforces currently.
If no following options, this will lead you to set all choosable compiler for each extensions, or only the specific extentions will be set. Options are c
,cpp
,and py
.
There are some common arguments can be used:
--config-path <path>
: specify the config directory. Default is$HOME/.codeforces-cli-tool
.--cookie-file <file>
: specify the cookie file name. Related toconfig-path
, default iscookie.json
.--compiler-file <file>
: specify the compiler file name. Related toconfig-path
, default iscompiler.json
.
$ npm install -g codeforces-cli-tool
$ codeforces set init
You can also manually add a empty file ~/.codeforces-cli-tool/cookie.json
to use default compiler settings without running init.
.c
usingGNU GCC C11 5.1.0
.cpp
and.cc
default usingGNU G++14 6.4.0
(changable).py
default usingPython 3.7.2
(changable).go
usingGo 1.8
.pl
usingPerl 5.20.1
.java
usingJava 1.8.0_131
.cs
usingC# Mono 5
.hs
usingHaskell GHC 7.8.3
If more extensions are needed, please issue it or send a PR.
- do not need to name file as problem code anymore
- command like
submit sol.cpp 977D
will work
- command like
- fetch sample testdata
- Sometime the submit can fail due to unknown 302 error. Just retry it.
Update to newer compiler options. (Not fully updated)
Fix minor problems.
Allow to set config-path, cookie-file, compiler-file in arguments.
Specify contests/gyms/mashups in options.
Allowing file name without contest id if this option is set.
Allow submit to contests/gyms. Submission in contests should work with this feature. Mashups is not tested.
Keep fixing fetch submission id issue.
Fit into new codeforces html format.
Fix bugs.
Add colors to verdict.
Live submission status are added.
Remove inquirer.
Show submission id after submit.
Prevent multiple command running at same time.
Add change log.
Add more languages (now accourding to problem status to add new language). I will add it after I saw it.
Add config
command (in version 1.2.0).
Make language(compiler) chooable.
Due to inquirer's rawlist display bug, try to use enquirer.
Change config
to set
.
Add login
command.
First time to write README
.
Use ~/.codeforces-cli-tool
directory to store files.
Register codeforces
command.
Make this package runnable.
Modulize some function in submit.
Store cookie to prevent login everytime.
Finish basic submit feature.
Add non-interactive mode, commands which use inquirer
banned in interactive mode.
Successul get CSRF token.
Readline will get inquirer input, maybe stdin confilct or something?
Project start.