-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathmain.go
54 lines (47 loc) · 1015 Bytes
/
main.go
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
53
54
package main
import (
"flag"
"fmt"
"testing"
"github.com/matryer/silk/runner"
)
var (
showVersion = flag.Bool("version", false, "show version and exit")
url = flag.String("silk.url", "", "(required) target url")
help = flag.Bool("help", false, "show help")
paths []string
)
func main() {
flag.Parse()
if *showVersion {
printversion()
return
}
if *help {
printhelp()
return
}
if *url == "" {
fmt.Println("silk.url argument is required")
return
}
paths = flag.Args()
testing.Main(func(pat, str string) (bool, error) { return true, nil },
[]testing.InternalTest{{Name: "silk", F: testFunc}},
nil,
nil)
}
func testFunc(t *testing.T) {
r := runner.New(t, *url)
fmt.Println("silk: running", len(paths), "file(s)...")
r.RunGlob(paths, nil)
}
func printhelp() {
printversion()
fmt.Println("usage: silk [file] [file2 [file3 [...]]")
fmt.Println(" e.g: silk ./test/*.silk.md")
flag.PrintDefaults()
}
func printversion() {
fmt.Println("silk", version)
}