Skip to content
This repository was archived by the owner on Dec 14, 2024. It is now read-only.

Commit 53c83a8

Browse files
committedApr 15, 2019
Update readme. Rename hack command to stand command
1 parent 75a01d1 commit 53c83a8

File tree

4 files changed

+104
-102
lines changed

4 files changed

+104
-102
lines changed
 

‎README.md

+57-61
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,51 @@
11
# Codeforces Tool
22

3+
[![Github release](https://img.shields.io/github/release/xalanq/cf-tool.svg)](https://github.com/xalanq/cf-tool/releases)
4+
[![platform](https://img.shields.io/badge/platform-win%20%7C%20osx%20%7C%20linux-blue.svg)](https://github.com/xalanq/cf-tool/releases)
35
[![Build Status](https://travis-ci.org/xalanq/cf-tool.svg?branch=master)](https://travis-ci.org/xalanq/cf-tool)
46
[![Go Report Card](https://goreportcard.com/badge/github.com/xalanq/cf-tool)](https://goreportcard.com/report/github.com/xalanq/cf-tool)
57
[![Go Version](https://img.shields.io/badge/go-%3E%3D1.12-green.svg)](https://github.com/golang)
68
[![license](https://img.shields.io/badge/license-MIT-%23373737.svg)](https://raw.githubusercontent.com/xalanq/cf-tool/master/LICENSE)
79

8-
Codeforces Tool is written by Golang. **It does not contain any browser driver** and it can be compiled to **a binary file**.
10+
Codeforces Tool is a tool for [Codeforces](https://codeforces.com).
11+
12+
It's fast, small, cross-platorm and powerful.
913

1014
## Features
1115

12-
* Submit a code to contest and **watch status dynamically**.
13-
* List problems statis in a contest.
14-
* Generate problem samples(parallel).
16+
* Submit a code to a contest.
17+
* Watch submissions' status dynamically.
18+
* List problems stats in a contest.
19+
* Parse problems' samples (parallel).
20+
* Generate code by templates.
1521
* Test samples.
16-
* Watch submissions.
17-
* Open page(problem, standing) with default browser.
18-
* Support code templates.
19-
* Cross-platform.
22+
* Use default web browser to open problem, standing page.
2023
* Colorful CLI.
2124

22-
Contributing is always welcome!
25+
Pull requests are always welcome.
2326

2427
![](./assets/readme_1.gif)
2528

26-
## TODO
27-
28-
* Support standing.
29-
* Support gym.
30-
* Support problemset.
31-
* Download someone's codes.
32-
* Support russian.
33-
* Scrape problems? I think we need to discuss for it. It's not a technical problem... [issue #1](https://github.com/xalanq/cf-tool/issues/1).
34-
35-
## Install
29+
## Installation
3630

3731
You can download the pre-compiled binary file in [here](https://github.com/xalanq/cf-tool/releases).
3832

39-
You can also compile from the source:
33+
Or you can compile it from the source:
4034

41-
```
35+
```plain
4236
$ git clone https://github.com/xalanq/cf-tool
4337
$ cd cf-tool
4438
$ go build -ldflags "-s -w" cf.go
4539
```
4640

4741
## Usage
4842

49-
**You should execute `cf config login` and `cf config add` at first.**
50-
51-
If you want to compete, the best command is `cf race 1111`, where `1111` is the contest id.
52-
5343
```plain
5444
Codeforces Tool (cf). https://github.com/xalanq/cf-tool
5545
56-
File:
57-
cf will save some data in following files:
58-
59-
"~/.cfconfig" config file, including username, encrypted password, etc.
60-
"~/.cfsession" session file, including cookies, username, etc.
46+
You should run "cf config login" and "cf config add" at first.
6147
62-
"~" is the homedir in your system
48+
If you want to compete, the best command is "cf race 1111", where "1111" is the contest id.
6349
6450
Usage:
6551
cf config (login | add | default)
@@ -71,43 +57,51 @@ Usage:
7157
cf test [<filename>]
7258
cf watch [<contest-id>]
7359
cf open [<contest-id>] [<problem-id>]
74-
cf hack [<contest-id>]
60+
cf stand [<contest-id>]
7561
cf race <contest-id>
7662
7763
Examples:
78-
cf config login Config username and password(encrypt).
79-
cf config add Add template.
64+
cf config login Config your username and password.
65+
cf config add Add a template.
8066
cf config default Set default template.
81-
cf submit Current path must be <contest-id>/<problem-id>/<file.[suffix]>.
82-
If there are multiple files which satisfy above condition, you
83-
have to choose one.
67+
cf submit Current path must be "<contest-id>/<problem-id>", cf will find which
68+
file can be submitted.
8469
cf submit a.cpp
8570
cf submit 100 a
8671
cf submit 100 a a.cpp
87-
cf list List current contest or <contest-id> problems' information.
88-
cf parse 100 Parse contest 100, all problems, including samples,
89-
into ./100/<problem-id>.
90-
cf parse 100 a Parse contest 100, problem a, including samples,
91-
into current path.
92-
cf gen Generate default template in current path (name as current path).
93-
cf gen cpp Generate template which alias is cpp in current path (same above).
94-
cf test Compile the source with build config first. Then test all samples.
95-
If there are multiple files, you have to choose one.
96-
cf watch Watch the first 10 submissions.
97-
cf open 1136 a Open page of contest 1136, problem a with default browser.
98-
cf open 1136 Open page of contest 1136 with default browser.
99-
cf hack Open standing page with default browser.
100-
cf race 1136 Race for contest. It will execute 'cf open 1136 a', 'cf open 1136 b',
101-
until 'cf open 1136 e', and 'cf parse 1136' when the contest begins.
72+
cf list List problems' stats of current contest.
73+
cf list 1119
74+
cf parse 100 Parse all problems of contest 100, including samples, into
75+
"./100/<problem-id>".
76+
cf parse 100 a Parse problem "a" of contest 100, including samples, into current path.
77+
cf gen Generate default template into current path.
78+
cf gen cpp Generate the template which's alias is "cpp" into current path.
79+
cf test Compile a source which satisfy at least one template's suffix.
80+
Then test all samples.
81+
cf watch Watch the first 10 submissionso of current contest.
82+
cf open 1136 a Use default web browser to open the page of contest 1136, problem a.
83+
cf open 1136 Use default web browser to open the page of contest 1136.
84+
cf stand Use default web browser to open the standing page.
85+
cf race 1136 Count down before contest 1136 begins. Then it will run 'cf open 1136 a',
86+
'cf open 1136 b', ..., 'cf open 1136 e', 'cf parse 1136' when the contest
87+
begins.
10288
10389
Notes:
10490
<problem-id> Could be "a" or "A", case-insensitive.
10591
<contest-id> Should be a number, you could find it in codeforces contest url.
106-
E.g. 1119 in https://codeforces.com/contest/1119.
92+
E.g. "1119" in "https://codeforces.com/contest/1119".
10793
<alias> Template's alias.
10894
95+
File:
96+
cf will save some data in following files:
97+
98+
"~/.cfconfig" configuration file, including username, encrypted password, etc.
99+
"~/.cfsession" session file, including cookies, username, etc.
100+
101+
"~" is the home directory of current user in your system.
102+
109103
Template:
110-
You can insert some placeholders in your template code. When generate a code from a
104+
You can insert some placeholders in your template code. When generate a code from the
111105
template, cf will replace all placeholders by following rules:
112106
113107
$%U%$ Username
@@ -123,16 +117,18 @@ Command:
123117
- before_script (execute once)
124118
- script (execute number of samples times)
125119
- after_script (execute once)
126-
You can set one of before_script and after_script to empty string,
127-
meaning not executing. You have to run your program in script(standard input/output).
120+
You could set "before_script" or "after_script" to empty string if you want,
121+
meaning not executing.
122+
You have to run your program in "script" with standard input/output (no need to
123+
redirect).
128124
129-
You can insert some placeholders in your commands. When execute these commands,
125+
You can insert some placeholders in your scripts. When execute a script,
130126
cf will replace all placeholders by following rules:
131127
132-
$%path%$ Path of test file (Excluding $%full%$, e.g. /home/xalanq/)
133-
$%full%$ Full name of test file (e.g. a.cpp)
134-
$%file%$ Name of testing file (Excluding suffix, e.g. a)
135-
$%rand%$ Random string with 8 character (including a-z 0-9)
128+
$%path%$ Path to source file (Excluding $%full%$, e.g. "/home/xalanq/")
129+
$%full%$ Full name of source file (e.g. "a.cpp")
130+
$%file%$ Name of source file (Excluding suffix, e.g. "a")
131+
$%rand%$ Random string with 8 character (including "a-z" "0-9")
136132
137133
Options:
138134
-h --help

‎cf.go

+43-37
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ import (
1212
func main() {
1313
usage := `Codeforces Tool (cf). https://github.com/xalanq/cf-tool
1414
15-
File:
16-
cf will save some data in following files:
15+
You should run "cf config login" and "cf config add" at first.
1716
18-
"~/.cfconfig" config file, including username, encrypted password, etc.
19-
"~/.cfsession" session file, including cookies, username, etc.
20-
21-
"~" is the homedir in your system
17+
If you want to compete, the best command is "cf race 1111", where "1111" is the contest id.
2218
2319
Usage:
2420
cf config (login | add | default)
@@ -30,43 +26,51 @@ Usage:
3026
cf test [<filename>]
3127
cf watch [<contest-id>]
3228
cf open [<contest-id>] [<problem-id>]
33-
cf hack [<contest-id>]
29+
cf stand [<contest-id>]
3430
cf race <contest-id>
3531
3632
Examples:
37-
cf config login Config username and password(encrypt).
38-
cf config add Add template.
33+
cf config login Config your username and password.
34+
cf config add Add a template.
3935
cf config default Set default template.
40-
cf submit Current path must be <contest-id>/<problem-id>/<file.[suffix]>.
41-
If there are multiple files which satisfy above condition, you
42-
have to choose one.
36+
cf submit Current path must be "<contest-id>/<problem-id>", cf will find which
37+
file can be submitted.
4338
cf submit a.cpp
4439
cf submit 100 a
4540
cf submit 100 a a.cpp
46-
cf list List current contest or <contest-id> problems' information.
47-
cf parse 100 Parse contest 100, all problems, including samples,
48-
into ./100/<problem-id>.
49-
cf parse 100 a Parse contest 100, problem a, including samples,
50-
into current path.
51-
cf gen Generate default template in current path (name as current path).
52-
cf gen cpp Generate template which alias is cpp in current path (same above).
53-
cf test Compile the source with build config first. Then test all samples.
54-
If there are multiple files, you have to choose one.
55-
cf watch Watch the first 10 submissions.
56-
cf open 1136 a Open page of contest 1136, problem a with default browser.
57-
cf open 1136 Open page of contest 1136 with default browser.
58-
cf hack Open standing page with default browser.
59-
cf race 1136 Race for contest. It will execute 'cf open 1136 a', 'cf open 1136 b',
60-
until 'cf open 1136 e', and 'cf parse 1136' when the contest begins.
41+
cf list List problems' stats of current contest.
42+
cf list 1119
43+
cf parse 100 Parse all problems of contest 100, including samples, into
44+
"./100/<problem-id>".
45+
cf parse 100 a Parse problem "a" of contest 100, including samples, into current path.
46+
cf gen Generate default template into current path.
47+
cf gen cpp Generate the template which's alias is "cpp" into current path.
48+
cf test Compile a source which satisfy at least one template's suffix.
49+
Then test all samples.
50+
cf watch Watch the first 10 submissionso of current contest.
51+
cf open 1136 a Use default web browser to open the page of contest 1136, problem a.
52+
cf open 1136 Use default web browser to open the page of contest 1136.
53+
cf stand Use default web browser to open the standing page.
54+
cf race 1136 Count down before contest 1136 begins. Then it will run 'cf open 1136 a',
55+
'cf open 1136 b', ..., 'cf open 1136 e', 'cf parse 1136' when the contest
56+
begins.
6157
6258
Notes:
6359
<problem-id> Could be "a" or "A", case-insensitive.
6460
<contest-id> Should be a number, you could find it in codeforces contest url.
65-
E.g. 1119 in https://codeforces.com/contest/1119.
61+
E.g. "1119" in "https://codeforces.com/contest/1119".
6662
<alias> Template's alias.
6763
64+
File:
65+
cf will save some data in following files:
66+
67+
"~/.cfconfig" configuration file, including username, encrypted password, etc.
68+
"~/.cfsession" session file, including cookies, username, etc.
69+
70+
"~" is the home directory of current user in your system.
71+
6872
Template:
69-
You can insert some placeholders in your template code. When generate a code from a
73+
You can insert some placeholders in your template code. When generate a code from the
7074
template, cf will replace all placeholders by following rules:
7175
7276
$%U%$ Username
@@ -82,22 +86,24 @@ Command:
8286
- before_script (execute once)
8387
- script (execute number of samples times)
8488
- after_script (execute once)
85-
You can set one of before_script and after_script to empty string,
86-
meaning not executing. You have to run your program in script(standard input/output).
89+
You could set "before_script" or "after_script" to empty string if you want,
90+
meaning not executing.
91+
You have to run your program in "script" with standard input/output (no need to
92+
redirect).
8793
88-
You can insert some placeholders in your commands. When execute these commands,
94+
You can insert some placeholders in your scripts. When execute a script,
8995
cf will replace all placeholders by following rules:
9096
91-
$%path%$ Path of test file (Excluding $%full%$, e.g. /home/xalanq/)
92-
$%full%$ Full name of test file (e.g. a.cpp)
93-
$%file%$ Name of testing file (Excluding suffix, e.g. a)
94-
$%rand%$ Random string with 8 character (including a-z 0-9)
97+
$%path%$ Path to source file (Excluding $%full%$, e.g. "/home/xalanq/")
98+
$%full%$ Full name of source file (e.g. "a.cpp")
99+
$%file%$ Name of source file (Excluding suffix, e.g. "a")
100+
$%rand%$ Random string with 8 character (including "a-z" "0-9")
95101
96102
Options:
97103
-h --help
98104
--version`
99105

100-
args, _ := docopt.Parse(usage, nil, true, "Codeforces Tool (cf) v0.3.1", false)
106+
args, _ := docopt.Parse(usage, nil, true, "Codeforces Tool (cf) v0.3.2", false)
101107
color.Output = ansi.NewAnsiStdout()
102108
config.Init()
103109
err := cmd.Eval(args)

‎cmd/browser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func Open(args map[string]interface{}) error {
2222
return open.Run(fmt.Sprintf("https://codeforces.com/contest/%v/problem/%v", contestID, problemID))
2323
}
2424

25-
// Hack command
26-
func Hack(args map[string]interface{}) error {
25+
// Stand command
26+
func Stand(args map[string]interface{}) error {
2727
contestID, err := getContestID(args)
2828
if err != nil {
2929
return err

‎cmd/cmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ func Eval(args map[string]interface{}) error {
3333
return Watch(args)
3434
} else if args["open"].(bool) {
3535
return Open(args)
36-
} else if args["hack"].(bool) {
37-
return Hack(args)
36+
} else if args["stand"].(bool) {
37+
return Stand(args)
3838
} else if args["race"].(bool) {
3939
return Race(args)
4040
}

0 commit comments

Comments
 (0)
This repository has been archived.