| 1 | package cliscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/ |
| 2 | |
| 3 | import "sortscip-go gomod github.com/golang/go/src go1.22 sort/" |
| 4 | |
| 5 | // CommandCategories interface allows for category manipulation |
| 6 | type CommandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategories# interface { |
| 7 | // AddCommand adds a command to a category, creating a new category if necessary. |
| 8 | AddCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategories#AddCommand.(category string, command *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) |
| 9 | // Categories returns a slice of categories sorted by name |
| 10 | Categoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategories#Categories.() []CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory# |
| 11 | } |
| 12 | |
| 13 | type commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories# []*commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory# |
| 14 | |
| 15 | func newCommandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/newCommandCategories().() CommandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategories# { |
| 16 | ret := commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#([]*commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#{}) |
| 17 | return &ret |
| 18 | } |
| 19 | |
| 20 | func (c *commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#) Lessscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#Less().(i, j int) bool { |
| 21 | return lexicographicLessscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/lexicographicLess().((*c)[i].Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#Name().(), (*c)[j].Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#Name().()) |
| 22 | } |
| 23 | |
| 24 | func (c *commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#) Lenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#Len().() int { |
| 25 | return len(*c) |
| 26 | } |
| 27 | |
| 28 | func (c *commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#) Swapscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#Swap().(i, j int) { |
| 29 | (*c)[i], (*c)[j] = (*c)[j], (*c)[i] |
| 30 | } |
| 31 | |
| 32 | func (c *commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#) AddCommandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#AddCommand().(category string, command *Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#) { |
| 33 | for _, commandCategory := range []*commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#(*c) { |
| 34 | if commandCategory.namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#name. == category { |
| 35 | commandCategory.commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands. = append(commandCategory.commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands., command) |
| 36 | return |
| 37 | } |
| 38 | } |
| 39 | newVal := append(*c, |
| 40 | &commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#{namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#name.: category, commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands.: []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{command}}) |
| 41 | *c = newVal |
| 42 | } |
| 43 | |
| 44 | func (c *commandCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#) Categoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategories#Categories().() []CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory# { |
| 45 | ret := make([]CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory#, len(*c)) |
| 46 | for i, cat := range *c { |
| 47 | ret[i] = cat |
| 48 | } |
| 49 | return ret |
| 50 | } |
| 51 | |
| 52 | // CommandCategory is a category containing commands. |
| 53 | type CommandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory# interface { |
| 54 | // Name returns the category name string |
| 55 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory#Name.() string |
| 56 | // VisibleCommands returns a slice of the Commands with Hidden=false |
| 57 | VisibleCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CommandCategory#VisibleCommands.() []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# |
| 58 | } |
| 59 | |
| 60 | type commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory# struct { |
| 61 | namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#name. string |
| 62 | commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands. []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# |
| 63 | } |
| 64 | |
| 65 | func (c *commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#) Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#Name().() string { |
| 66 | return c.namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#name. |
| 67 | } |
| 68 | |
| 69 | func (c *commandCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#) VisibleCommandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#VisibleCommands().() []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# { |
| 70 | if c.commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands. == nil { |
| 71 | c.commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands. = []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#{} |
| 72 | } |
| 73 | |
| 74 | var ret []*Commandscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command# |
| 75 | for _, command := range c.commandsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/commandCategory#commands. { |
| 76 | if !command.Hiddenscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Command#Hidden. { |
| 77 | ret = append(ret, command) |
| 78 | } |
| 79 | } |
| 80 | return ret |
| 81 | } |
| 82 | |
| 83 | // FlagCategories interface allows for category manipulation |
| 84 | type FlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories# interface { |
| 85 | // AddFlags adds a flag to a category, creating a new category if necessary. |
| 86 | AddFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories#AddFlag.(category string, fl Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) |
| 87 | // VisibleCategories returns a slice of visible flag categories sorted by name |
| 88 | VisibleCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories#VisibleCategories.() []VisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory# |
| 89 | } |
| 90 | |
| 91 | type defaultFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories# struct { |
| 92 | mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m. map[string]*defaultVisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory# |
| 93 | } |
| 94 | |
| 95 | func newFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/newFlagCategories().() FlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories# { |
| 96 | return &defaultFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#{ |
| 97 | mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m.: map[string]*defaultVisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#{}, |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func newFlagCategoriesFromFlagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/newFlagCategoriesFromFlags().(fs []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) FlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories# { |
| 102 | fc := newFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/newFlagCategories().() |
| 103 | |
| 104 | var categorized bool |
| 105 | |
| 106 | for _, fl := range fs { |
| 107 | if cf, ok := fl.(CategorizableFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CategorizableFlag#); ok { |
| 108 | visible := false |
| 109 | if vf, ok := fl.(VisibleFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlag#); ok { |
| 110 | visible = vf.IsVisiblescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlag#IsVisible.() |
| 111 | } |
| 112 | if cat := cf.GetCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CategorizableFlag#GetCategory.(); cat != "" && visible { |
| 113 | fc.AddFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories#AddFlag.(cat, fl) |
| 114 | categorized = true |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if categorized { |
| 120 | for _, fl := range fs { |
| 121 | if cf, ok := fl.(CategorizableFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CategorizableFlag#); ok { |
| 122 | visible := false |
| 123 | if vf, ok := fl.(VisibleFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlag#); ok { |
| 124 | visible = vf.IsVisiblescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlag#IsVisible.() |
| 125 | } |
| 126 | if cf.GetCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/CategorizableFlag#GetCategory.() == "" && visible { |
| 127 | fc.AddFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/FlagCategories#AddFlag.("", fl) |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return fc |
| 134 | } |
| 135 | |
| 136 | func (f *defaultFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#) AddFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#AddFlag().(category string, fl Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#) { |
| 137 | if _, ok := f.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m.[category]; !ok { |
| 138 | f.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m.[category] = &defaultVisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#{namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#name.: category, mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#m.: map[string]Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#{}} |
| 139 | } |
| 140 | |
| 141 | f.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m.[category].mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#m.[fl.Stringscip-go gomod github.com/golang/go/src go1.22 fmt/Stringer#String().()] = fl |
| 142 | } |
| 143 | |
| 144 | func (f *defaultFlagCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#) VisibleCategoriesscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#VisibleCategories().() []VisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory# { |
| 145 | catNames := []string{} |
| 146 | for name := range f.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m. { |
| 147 | catNames = append(catNames, name) |
| 148 | } |
| 149 | |
| 150 | sortscip-go gomod github.com/golang/go/src go1.22 sort/.Stringsscip-go gomod github.com/golang/go/src go1.22 sort/Strings().(catNames) |
| 151 | |
| 152 | ret := make([]VisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory#, len(catNames)) |
| 153 | for i, name := range catNames { |
| 154 | ret[i] = f.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultFlagCategories#m.[name] |
| 155 | } |
| 156 | |
| 157 | return ret |
| 158 | } |
| 159 | |
| 160 | // VisibleFlagCategory is a category containing flags. |
| 161 | type VisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory# interface { |
| 162 | // Name returns the category name string |
| 163 | Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory#Name.() string |
| 164 | // Flags returns a slice of VisibleFlag sorted by name |
| 165 | Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlagCategory#Flags.() []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 166 | } |
| 167 | |
| 168 | type defaultVisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory# struct { |
| 169 | namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#name. string |
| 170 | mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#m. map[string]Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# |
| 171 | } |
| 172 | |
| 173 | func (fc *defaultVisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#) Namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#Name().() string { |
| 174 | return fc.namescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#name. |
| 175 | } |
| 176 | |
| 177 | func (fc *defaultVisibleFlagCategoryscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#) Flagsscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#Flags().() []Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag# { |
| 178 | vfNames := []string{} |
| 179 | for flName, fl := range fc.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#m. { |
| 180 | if vf, ok := fl.(VisibleFlagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlag#); ok { |
| 181 | if vf.IsVisiblescip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/VisibleFlag#IsVisible.() { |
| 182 | vfNames = append(vfNames, flName) |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | sortscip-go gomod github.com/golang/go/src go1.22 sort/.Stringsscip-go gomod github.com/golang/go/src go1.22 sort/Strings().(vfNames) |
| 188 | |
| 189 | ret := make([]Flagscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/Flag#, len(vfNames)) |
| 190 | for i, flName := range vfNames { |
| 191 | ret[i] = fc.mscip-go gomod github.com/urfave/cli/v3 . `github.com/urfave/cli/v3`/defaultVisibleFlagCategory#m.[flName] |
| 192 | } |
| 193 | |
| 194 | return ret |
| 195 | } |