MCPcopy
hub / github.com/go-task/task / Validate

Function Validate

internal/flags/flags.go:206–253  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

204}
205
206func Validate() error {
207 if Download && Offline {
208 return errors.New("task: You can't set both --download and --offline flags")
209 }
210
211 if Download && ClearCache {
212 return errors.New("task: You can't set both --download and --clear-cache flags")
213 }
214
215 if Global && Dir != "" {
216 return errors.New("task: You can't set both --global and --dir")
217 }
218
219 if Output.Name != "group" {
220 if Output.Group.Begin != "" {
221 return errors.New("task: You can't set --output-group-begin without --output=group")
222 }
223 if Output.Group.End != "" {
224 return errors.New("task: You can't set --output-group-end without --output=group")
225 }
226 if Output.Group.ErrorOnly {
227 return errors.New("task: You can't set --output-group-error-only without --output=group")
228 }
229 }
230
231 if List && ListAll {
232 return errors.New("task: cannot use --list and --list-all at the same time")
233 }
234
235 if ListJson && !List && !ListAll {
236 return errors.New("task: --json only applies to --list or --list-all")
237 }
238
239 if NoStatus && !ListJson {
240 return errors.New("task: --no-status only applies to --json with --list or --list-all")
241 }
242
243 if Nested && !ListJson {
244 return errors.New("task: --nested only applies to --json with --list or --list-all")
245 }
246
247 // Validate certificate flags
248 if (Cert != "" && CertKey == "") || (Cert == "" && CertKey != "") {
249 return errors.New("task: --cert and --cert-key must be provided together")
250 }
251
252 return nil
253}
254
255// WithFlags is a special internal functional option that is used to pass flags
256// from the CLI into any constructor that accepts functional options.

Callers 1

runFunction · 0.92

Calls 1

NewFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…