-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
help.go
202 lines (169 loc) · 4.99 KB
/
help.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package main
import (
"strings"
)
func printHelp(cmd string) {
printSplash()
switch cmd {
case subcommandTerraform:
printTerraformHelp()
case subcommandSimulate:
printSimulateHelp()
case subcommandStats:
printStatsHelp()
case subcommandTest:
printTestHelp()
case subcommandLint:
printLintHelp()
case subcommandConsole:
printConsoleHelp()
case subcommandFormat:
printFormatHelp()
default:
printGlobalHelp()
}
}
func printSplash() {
writeln(white, strings.TrimSpace(`
=========================================================
____ __
/ __/______ / /_____ ____
/ /_ / __ `+` // // __// __ \
/ __// /_/ // // /__ / /_/ /
/_/ \____//_/ \___/ \____/ Fastly VCL developer tool
=========================================================
`))
}
func printGlobalHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco [subcommand] [flags] [main vcl file]
Subcommands:
lint : Run lint (default)
terraform : Run lint from terraform planned JSON
stats : Analyze VCL statistics
simulate : Run simulator server with provided VCLs
test : Run local testing for provided VCLs
console : Run terminal console
fmt : Run formatter for provided VCLs
See subcommands help with:
falco [subcommand] -h
All Flags:
-I, --include_path : Add include path
-h, --help : Show this help
-r, --remote : Connect with Fastly API
-V, --version : Display build version
-v : Output lint warnings (verbose)
-vv : Output all lint results (very verbose)
-json : Output results as JSON (very verbose)
Simple linting example:
falco -I . -vv /path/to/vcl/main.vcl
`))
}
func printTerraformHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco terraform [action] [flags]
Actions:
lint : Run lint (default)
stats : Analyze VCL statistics
simulate : Run simulator server with planned JSON
test : Run local testing for planned JSON
Flags:
-I, --include_path : Add include path
-h, --help : Show this help
-v : Output lint warnings (verbose)
-vv : Output all lint results (very verbose)
-json : Output results as JSON (very verbose)
Linting with terraform:
terraform plan -out planned.out
terraform show -json planned.out | falco -vv terraform
`))
}
func printSimulateHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco simulate [flags] file
Flags:
-I, --include_path : Add include path
-h, --help : Show this help
-r, --remote : Connect with Fastly API
-request : Simulate request config
-debug : Enable debug mode
--max_backends : Override max backends limitation
--max_acls : Override max acls limitation
Local simulator example:
falco simulate -I . /path/to/vcl/main.vcl
Local debugger example:
falco simulate -I . -debug /path/to/vcl/main.vcl
`))
}
func printStatsHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco stats [flags] file
Flags:
-I, --include_path : Add include path
-h, --help : Show this help
-r, --remote : Connect with Fastly API
-json : Output results as JSON
Get statistics example:
falco stats -I . /path/to/vcl/main.vcl
`))
}
func printTestHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco test [flags]
Flags:
-I, --include_path : Add include path
-h, --help : Show this help
-r, --remote : Connect with Fastly API
-t, --timeout : Set timeout to running test
-f, --filter : Override glob filter to find test files
-json : Output results as JSON
-request : Override request config
--max_backends : Override max backends limitation
--max_acls : Override max acls limitation
Local testing example:
falco test -I . -I ./tests /path/to/vcl/main.vcl
`))
}
func printLintHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco lint [flags] file
Flags:
-I, --include_path : Add include path
-h, --help : Show this help
-r, --remote : Connect with Fastly API
-v : Output lint warnings (verbose)
-vv : Output all lint results (very verbose)
-json : Output results as JSON (very verbose)
Simple linting with very verbose example:
falco lint -I . -vv /path/to/vcl/main.vcl
`))
}
func printConsoleHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco console [flags]
Flags:
-s, --scope : Define initial scope
-h, --help : Show this help
Run console with fetch scope example:
falco console -s fetch
`))
}
func printFormatHelp() {
writeln(white, strings.TrimSpace(`
Usage:
falco fmt [flags] ...files
Flags:
-h, --help : Show this help
-w, --write : Overwrite format result
files argument accepts glob file patterns
Simple format example:
falco fmt /path/to/vcl/main.vcl
`))
}