Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit 6d15dc9

Browse files
authored
make contest create command create testcases directory (#57)
1 parent 084fea2 commit 6d15dc9

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ FLAGS := -ldflags "$(LD_FLAGS)"
77

88
.PHONY: install clean build ach test lint yamllint generate-docs dry-release
99

10-
default: build test lint yamllint generate-docs
10+
default: fmt build test lint yamllint generate-docs
1111

12-
all: build test yamllint lint generate-docs dry-release
12+
all: fmt build test yamllint lint generate-docs dry-release
1313

1414
install:
1515
go install ./cmd/ach
1616

1717

1818
build: ach gendocs
1919

20+
fmt:
21+
gofumpt -w .
22+
2023

2124
ach:
2225
go build ${FLAGS} -o ./bin/ach ./cmd/ach/main.go

internal/cmd/ach/contest/create/create.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package create
22

33
import (
4+
"fmt"
45
"log"
56
"os/exec"
67
"os/user"
@@ -34,11 +35,29 @@ D is for directory.
3435

3536
for _, taskName := range taskNames {
3637
taskDirName := path.Join(contestName, taskName)
37-
3838
err := exec.Command("cp", "-r", templateDirName, taskDirName).Run()
3939
if err != nil {
4040
return err
4141
}
42+
43+
sampleDirName := path.Join(taskDirName, "sampleCases")
44+
err = exec.Command("mkdir", sampleDirName).Run()
45+
if err != nil {
46+
return err
47+
}
48+
49+
for i := 1; i <= 5; i++ {
50+
inputFileName := path.Join(sampleDirName, fmt.Sprintf("case%d.input", i))
51+
err = exec.Command("touch", inputFileName).Run()
52+
if err != nil {
53+
return err
54+
}
55+
outputFileName := path.Join(sampleDirName, fmt.Sprintf("case%d.output", i))
56+
err = exec.Command("touch", outputFileName).Run()
57+
if err != nil {
58+
return err
59+
}
60+
}
4261
}
4362

4463
return nil

0 commit comments

Comments
 (0)