attr: flag test methods (#177)
Adds a method to the Attribute type to test for each flag in the textflag.h header.
This commit is contained in:
committed by
GitHub
parent
c5faaae583
commit
e9f28cafb8
@@ -197,4 +197,10 @@ func PrintFlagAttributes(w io.Writer, fs []Flag) {
|
||||
fmt.Fprintf(w, "\t%s: %q,\n", f.Name, f.Name)
|
||||
}
|
||||
fmt.Fprintf(w, "}\n")
|
||||
|
||||
// Flag test methods.
|
||||
for _, f := range fs {
|
||||
fmt.Fprintf(w, "\n// %s reports whether the %s flag is set.\n", f.Name, f.Name)
|
||||
fmt.Fprintf(w, "func (a Attribute) %s() bool { return (a & %s) != 0 }\n", f.Name, f.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user