Crates.io | caffeine-cf |
lib.rs | caffeine-cf |
version | 0.1.3 |
source | src |
created_at | 2021-03-14 09:41:45.711931 |
updated_at | 2021-03-22 15:46:36.849587 |
description | CLI tool for accessing the Codeforces API easily. |
homepage | |
repository | https://github.com/thud/caffeine |
max_upload_size | |
id | 368737 |
size | 143,285 |
Caffeine is a CLI tool which allows you to easily interact with the Codeforces API from your terminal or from custom scripts.
caffeine [FLAGS] [OPTIONS] [SUBCOMMAND]
Options can be listed with caffeine --help
.
cargo
Package Managercargo install caffeine-cf
To compile manually, first clone this repo.
git clone https://github.com/thud/caffeine
Then, you can build and run with cargo run
. eg:
cargo r -- user info thud
This utility uses the
codeforces-api
crate to allow
you to interact with the
Codeforces API from the command line or
from within a custom script.
stdin
.As of the current version of the
codeforces-api
crate, an API
key and secret is required with every request made. Instructions to
generate these can be found here (in the
Authorization section). To provide caffeine
with your key/secret, you
will need to either run caffeine login
or provide them as arguments by
using the --key
/-k
and --secret
/-s
flags (see caffeine help
). It
is recommended that you use cargo login
instead of CLI flags since your
key and secret may be visible in your shell command history.
Solutions are submitted by using the
headless_chrome
crate. This
requires you to have a chromium-based browser installed in order for it to
work. If your browser is not auto-detected by headless_chrome
, then you
should try setting the CHROME
environment variable before running. For
Brave browser, for example, you might run export CHROME=/usr/bin/brave
.
Submitting solutions also requires that you provide your username and
password. You can provide these with caffeine login
or more explicitly
with the --handle
/-H
and --password
/-p
flags.
For an example use-case for caffeine
, see the cpsetup
(mostly POSIX compliant) shell script. It provides a comprehensive example of
how caffeine
could be utilised in a script to provide the user with lots of
useful functionality.