LocalFlagNames returns a slice of flag names used in this command.
()
| 518 | // LocalFlagNames returns a slice of flag names used in this |
| 519 | // command. |
| 520 | func (cmd *Command) LocalFlagNames() []string { |
| 521 | names := []string{} |
| 522 | |
| 523 | // Check the flags which have been set via env or file |
| 524 | for _, f := range cmd.allFlags() { |
| 525 | if f.IsSet() { |
| 526 | names = append(names, f.Names()...) |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | // Sort out the duplicates since flag could be set via multiple |
| 531 | // paths |
| 532 | m := map[string]struct{}{} |
| 533 | uniqNames := []string{} |
| 534 | |
| 535 | for _, name := range names { |
| 536 | if _, ok := m[name]; !ok { |
| 537 | m[name] = struct{}{} |
| 538 | uniqNames = append(uniqNames, name) |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | return uniqNames |
| 543 | } |
| 544 | |
| 545 | // FlagNames returns a slice of flag names used by the this command |
| 546 | // and all of its parent commands. |