Skip to content

Commit 40271db

Browse files
committed
Print help w/o arguments and exit w/zero.
1 parent 007800f commit 40271db

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

validator.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,48 @@ const (
3030
FailAssertResponseHeaderValue
3131
)
3232

33+
const DEFAULT_SPEC_FILE = "urls.json"
34+
const MANUAL = `Usage: validate-http-headers SPECFILES...
35+
Iterates through SPECFILES, making requests and validating responses headers
36+
37+
Multiple JSON specs can be passed
38+
39+
$ ./validate-http-headers internal.json external.json mtv.json
40+
41+
Non-zero exit codes indicate failure. All failures begin with "FAIL: "; exit
42+
code constants can be found in validator.go.
43+
44+
Simple spec:
45+
46+
{
47+
"default": {
48+
"requestHeaders": {
49+
"Referer": ["https://bad-website.com"]
50+
},
51+
"responseHeaders": {
52+
"X-Frame-Options": ["SAMEORIGIN"]
53+
}
54+
},
55+
56+
"specs": [
57+
{
58+
"url": "https://www.google.com/"
59+
},
60+
{
61+
"url": "https://drive.google.com/"
62+
}
63+
]
64+
}
65+
66+
Full documentation at: <https://github.com/talee/validate-http-headers>`
67+
3368
func main() {
3469
var filenames []string
3570
if len(os.Args) == 1 {
71+
if _, err := os.Stat(DEFAULT_SPEC_FILE); os.IsNotExist(err) {
72+
fmt.Println(MANUAL)
73+
os.Exit(0)
74+
}
3675
filenames = []string{"urls.json"}
3776
} else {
3877
filenames = os.Args[1:]

0 commit comments

Comments
 (0)