Debian Codegraph @

flag_mutex.go

raw symbols SCIP
1 package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/
2
3 // MutuallyExclusiveFlags defines a mutually exclusive flag group
4 // Multiple option paths can be provided out of which
5 // only one can be defined on cmdline
6 // So for example
7 // [ --foo | [ --bar something --darth somethingelse ] ]
8 type MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags# struct {
9 // Flag list
10 Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Flags. [][]Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#
11
12 // whether this group is required
13 Requiredscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Required. bool
14
15 // Category to apply to all flags within group
16 Categoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Category. string
17 }
18
19 func (grp MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#) checkscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#check().(_ *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) error {
20 oneSet := false
21 e := &mutuallyExclusiveGroupscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/mutuallyExclusiveGroup#{}
22
23 for _, grpf := range grp.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Flags. {
24 for _, f := range grpf {
25 if f.IsSetscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#IsSet.() {
26 if oneSet {
27 e.flag2Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/mutuallyExclusiveGroup#flag2Name. = f.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.()[0]
28 return e
29 }
30 e.flag1Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/mutuallyExclusiveGroup#flag1Name. = f.Namesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#Names.()[0]
31 oneSet = true
32 break
33 }
34 if oneSet {
35 break
36 }
37 }
38 }
39
40 if !oneSet && grp.Requiredscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Required. {
41 return &mutuallyExclusiveGroupRequiredFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/mutuallyExclusiveGroupRequiredFlag#{flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/mutuallyExclusiveGroupRequiredFlag#flags.: &grp}
42 }
43 return nil
44 }
45
46 func (grp MutuallyExclusiveFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#) propagateCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#propagateCategory().() {
47 for _, grpf := range grp.Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Flags. {
48 for _, f := range grpf {
49 if cf, ok := f.(CategorizableFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CategorizableFlag#); ok {
50 cf.SetCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CategorizableFlag#SetCategory.(grp.Categoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/MutuallyExclusiveFlags#Category.)
51 }
52 }
53 }
54 }