-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
52 lines (44 loc) · 845 Bytes
/
main.go
File metadata and controls
52 lines (44 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"dsa/hack/boilerplate"
"fmt"
"os"
)
func main() {
fmt.Println("--- DSA Practice ---")
tempDir := "temp"
if _, err := os.Stat(tempDir); err != nil {
fmt.Printf("%v, create %s and try again\n", err, tempDir)
os.Exit(0)
}
args := os.Args[1:]
if len(args) != 4 {
printUsage()
fmt.Println("missing command, pattern, difficulty and title")
os.Exit(0)
}
metadata, err := boilerplate.ValidMetadata(
boilerplate.NewMetadata(
args[0],
args[1],
args[2],
args[3],
),
)
if err != nil {
panic(err)
}
generator := boilerplate.NewGenerator(
boilerplate.NewConfig(
"hack/boilerplate/docs.gotmpl",
tempDir,
metadata,
),
)
if err := generator.Run(); err != nil {
panic(err)
}
}
func printUsage() {
fmt.Println("Usage: go run . <command> <pattern> <difficulty> <title>")
}