Add missing set docs
This commit is contained in:
parent
0e385a785c
commit
204cedcd68
@ -3,6 +3,8 @@ package flags
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hashicorp/go-multierror"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrorHandling uint
|
type ErrorHandling uint
|
||||||
@ -35,18 +37,21 @@ type Set struct {
|
|||||||
type SetModifier func(s *Set)
|
type SetModifier func(s *Set)
|
||||||
type Visitor func(f *Flag)
|
type Visitor func(f *Flag)
|
||||||
|
|
||||||
|
// Set the error handling mode for the Set
|
||||||
func SetErrorMode(m ErrorHandling) SetModifier {
|
func SetErrorMode(m ErrorHandling) SetModifier {
|
||||||
return func(s *Set) {
|
return func(s *Set) {
|
||||||
s.errorHandling = m
|
s.errorHandling = m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the mode for handling unknown flags
|
||||||
func SetUnknownMode(m UnknownHandling) SetModifier {
|
func SetUnknownMode(m UnknownHandling) SetModifier {
|
||||||
return func(s *Set) {
|
return func(s *Set) {
|
||||||
s.unknownHandling = m
|
s.unknownHandling = m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new set
|
||||||
func NewSet(name string, modifiers ...SetModifier) *Set {
|
func NewSet(name string, modifiers ...SetModifier) *Set {
|
||||||
s := &Set{
|
s := &Set{
|
||||||
name: name,
|
name: name,
|
||||||
@ -104,6 +109,8 @@ func (s *Set) VisitAll(fn Visitor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a group to the set. This is used to relocate
|
||||||
|
// a group from one set to another.
|
||||||
func (s *Set) AddGroup(g *Group) error {
|
func (s *Set) AddGroup(g *Group) error {
|
||||||
// Check that group hasn't already been added
|
// Check that group hasn't already been added
|
||||||
for _, cg := range s.groups {
|
for _, cg := range s.groups {
|
||||||
@ -160,6 +167,8 @@ func (s *Set) Flags() []*Flag {
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a flag by name. If the set has parsed, flags
|
||||||
|
// can be retrieved using short name and aliases.
|
||||||
func (s *Set) Flag(n string) (f *Flag, err error) {
|
func (s *Set) Flag(n string) (f *Flag, err error) {
|
||||||
if s.parsed {
|
if s.parsed {
|
||||||
f = s.flagMap[n]
|
f = s.flagMap[n]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user