-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors-flag.go
37 lines (30 loc) · 1.07 KB
/
errors-flag.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
package argo
import (
"fmt"
)
// ////////////////////////////////////////////////////////////////////////// //
// //
// Missing Flag Error //
// //
// ////////////////////////////////////////////////////////////////////////// //
// A MissingFlagError is returned on CLI parse when a flag that has been marked
// as being required was not found to be present in the CLI call.
//
// MissingFlagError is a hard error that will be returned regardless of whether
// the parser is operating in strict mode.
type MissingFlagError interface {
error
Flag() Flag
}
func newMissingFlagError(flag Flag) MissingFlagError {
return missingFlagError{flag}
}
type missingFlagError struct {
flag Flag
}
func (m missingFlagError) Error() string {
return fmt.Sprintf("required flag %s was missing from the CLI call", printFlagNames(m.flag))
}
func (m missingFlagError) Flag() Flag {
return m.flag
}