Install shared reporting flags
This commit is contained in:
@@ -18,8 +18,10 @@ type Command struct {
|
||||
Description string
|
||||
Runnable bool
|
||||
Flags []Flag
|
||||
Arguments []Argument
|
||||
Children []*Command
|
||||
// CoreFlags are parsed by CommandKit but do not occupy consumer binding indexes.
|
||||
CoreFlags []Flag
|
||||
Arguments []Argument
|
||||
Children []*Command
|
||||
}
|
||||
|
||||
// Argument describes one positional input for usage rendering.
|
||||
@@ -41,6 +43,26 @@ type Flag struct {
|
||||
Required bool
|
||||
}
|
||||
|
||||
var reportingFlags = [...]Flag{
|
||||
{Name: "quiet", Usage: "suppress substantive output and optional messages; keep failures visible", Default: "false", Boolean: true},
|
||||
{Name: "verbose", Usage: "show warning and informational messages", Default: "false", Boolean: true},
|
||||
{Name: "debug", Usage: "show debugging messages", Default: "false", Boolean: true},
|
||||
{Name: "progress", Usage: "show progress messages", Default: "false", Boolean: true},
|
||||
}
|
||||
|
||||
// ReportingFlags returns the flags shared by CommandKit's invocation reporter.
|
||||
func ReportingFlags() []Flag { return append([]Flag(nil), reportingFlags[:]...) }
|
||||
|
||||
// IsReportingFlag reports whether name is reserved for a shared reporting flag.
|
||||
func IsReportingFlag(name string) bool {
|
||||
for _, flag := range reportingFlags {
|
||||
if flag.Name == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// FlagAlias maps one option spelling to a canonical flag spelling.
|
||||
type FlagAlias struct {
|
||||
Source string
|
||||
@@ -58,6 +80,7 @@ type HelpView struct {
|
||||
EnteredPath []string
|
||||
CanonicalPath []string
|
||||
Discovery bool
|
||||
CoreFlags []Flag
|
||||
CommandAliases []CommandAlias
|
||||
FlagAliases []FlagAlias
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user