(showRetired bool)
| 14 | ) |
| 15 | |
| 16 | func (cli *cliConfig) featureFlags(showRetired bool) error { |
| 17 | green := color.New(color.FgGreen).SprintFunc() |
| 18 | red := color.New(color.FgRed).SprintFunc() |
| 19 | yellow := color.New(color.FgYellow).SprintFunc() |
| 20 | magenta := color.New(color.FgMagenta).SprintFunc() |
| 21 | |
| 22 | printFeature := func(feat fflag.Feature) { |
| 23 | nameDesc := feat.Name |
| 24 | if feat.Description != "" { |
| 25 | nameDesc += ": " + feat.Description |
| 26 | } |
| 27 | |
| 28 | status := red("✗") |
| 29 | if feat.IsEnabled() { |
| 30 | status = green("✓") |
| 31 | } |
| 32 | |
| 33 | fmt.Fprintf(os.Stdout, "%s %s", status, nameDesc) |
| 34 | |
| 35 | if feat.State == fflag.DeprecatedState { |
| 36 | fmt.Fprintf(os.Stdout, "\n %s %s", yellow("DEPRECATED"), feat.DeprecationMsg) |
| 37 | } |
| 38 | |
| 39 | if feat.State == fflag.RetiredState { |
| 40 | fmt.Fprintf(os.Stdout, "\n %s %s", magenta("RETIRED"), feat.DeprecationMsg) |
| 41 | } |
| 42 | |
| 43 | fmt.Fprintln(os.Stdout) |
| 44 | } |
| 45 | |
| 46 | feats := fflag.Crowdsec.GetAllFeatures() |
| 47 | |
| 48 | enabled := []fflag.Feature{} |
| 49 | disabled := []fflag.Feature{} |
| 50 | retired := []fflag.Feature{} |
| 51 | |
| 52 | for _, feat := range feats { |
| 53 | if feat.State == fflag.RetiredState { |
| 54 | retired = append(retired, feat) |
| 55 | continue |
| 56 | } |
| 57 | |
| 58 | if feat.IsEnabled() { |
| 59 | enabled = append(enabled, feat) |
| 60 | continue |
| 61 | } |
| 62 | |
| 63 | disabled = append(disabled, feat) |
| 64 | } |
| 65 | |
| 66 | if len(enabled) > 0 { |
| 67 | fmt.Fprintln(os.Stdout, " --- Enabled features ---") |
| 68 | fmt.Fprintln(os.Stdout) |
| 69 | |
| 70 | for _, feat := range enabled { |
| 71 | printFeature(feat) |
| 72 | } |
| 73 |
no test coverage detected