Skip to content

Commit ab42648

Browse files
authored
add description of templates
1 parent 456bab0 commit ab42648

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,105 @@ $ acc config <key> <value> # set option
4545
$ cd `acc config-dir`
4646
$ cat config.json # global config file
4747
```
48+
## Provisioning Templates
49+
With using custom templates, you can automatically prepare your template program code or build environment.
50+
51+
When you create new task directories, atcoder-tools can do:
52+
- copy the base program file
53+
- copy static files
54+
- exec shell command
55+
56+
show available templates:
57+
```sh
58+
$ acc templates
59+
```
60+
61+
use the template:
62+
```sh
63+
$ acc new|add --template <your-template-name>
64+
```
65+
66+
Or you can set default template:
67+
```sh
68+
$ acc config default-template <your-template-name>
69+
```
70+
71+
### Create a new template
72+
```sh
73+
$ cd `acc config-dir`
74+
$ mkdir <your-template-name>
75+
$ cd <your-template-name>
76+
$ vim template.json # write your template settings
77+
```
78+
79+
### Options in template.json
80+
```json
81+
{
82+
"program": ["main.cpp", ["foo.cpp", "{TaskID}.cpp"]],
83+
"submit": "main.cpp",
84+
"static": ["foo", ["gitignore",".gitignore"]],
85+
"testdir": "tests_{TaskID}",
86+
"cmd": "echo 'HI!'"
87+
}
88+
```
89+
90+
#### `"program"` (required)
91+
```ts
92+
"program": (string | [string, string])[]
93+
```
94+
95+
Your main program(s).
96+
Place main.cpp in the same directory of template.json, and write
97+
```
98+
"program": ["main.cpp"]
99+
```
100+
then the program file will be copied to the task directory.
101+
102+
You can rename the file with format strings:
103+
```
104+
"program": [["main.cpp", "{TaskId}.cpp"]]
105+
```
106+
The file name of the program file will be "A.cpp" if the task is problem A.
107+
108+
To get detailed information about format strings, use `acc format -h`.
109+
110+
#### `"submit"` (required)
111+
```ts
112+
"submit": string
113+
```
114+
115+
The file name to submit.
116+
It enables to omit the filename argument to submit file, so you can run `acc submit` instead of `acc submit <filename>`.
117+
118+
Format strings are supported.
119+
120+
#### `"static"` (optional)
121+
```ts
122+
"static": (string | [string, string])[]
123+
```
124+
125+
Static assets.
126+
The difference between `"program"` and `"static"` is:
127+
- `"program"` files won't be overwrited when using `acc add --force`.
128+
- `"static"` files will be overwrited when using `acc add --force`.
129+
130+
#### `"testdir"` (optional)
131+
```ts
132+
"testdir": string
133+
```
134+
135+
The name of the directory that sample cases will be downloaded.
136+
Without this, the directory name will be the value of `acc config default-test-dirname-format`.
137+
138+
Format strings are supported.
139+
140+
#### `"cmd"` (optional)
141+
```ts
142+
"cmd": string
143+
```
144+
After copying files and downloading sample cases, the specified command will be executed.
145+
146+
The working directory is the task directory.
147+
148+
Parameters are given as enviromental variables:
149+
`$TEMPLATE_DIR`, `$TASK_DIR`, `$TASK_ID`, `$TASK_INDEX` and `$CONTEST_ID`

0 commit comments

Comments
 (0)