HasAlias returns true if the command alias is in the command list.
(alias string)
| 226 | |
| 227 | // HasAlias returns true if the command alias is in the command list. |
| 228 | func (c commandList) HasAlias(alias string) bool { |
| 229 | if alias == "" { |
| 230 | return false |
| 231 | } |
| 232 | |
| 233 | cType := reflect.TypeOf(c) |
| 234 | _, found := cType.FieldByNameFunc( |
| 235 | func(fieldName string) bool { |
| 236 | field, _ := cType.FieldByName(fieldName) |
| 237 | return field.Tag.Get("alias") == alias |
| 238 | }, |
| 239 | ) |
| 240 | |
| 241 | return found |
| 242 | } |