MCPcopy
hub / github.com/crowdsecurity/crowdsec / remove

Method remove

cmd/crowdsec-cli/cliitem/cmdremove.go:89–119  ·  view source on GitHub ↗
(ctx context.Context, args []string, interactive bool, dryRun bool, purge bool, force bool, all bool)

Source from the content-addressed store, hash-verified

87}
88
89func (cli *cliItem) remove(ctx context.Context, args []string, interactive bool, dryRun bool, purge bool, force bool, all bool) error {
90 cfg := cli.cfg()
91
92 hub, err := require.Hub(cli.cfg(), log.StandardLogger())
93 if err != nil {
94 return err
95 }
96
97 plan, err := cli.removePlan(hub, args, purge, force, all)
98 if err != nil {
99 return err
100 }
101
102 showPlan := (log.StandardLogger().Level >= log.InfoLevel)
103 verbosePlan := (cfg.Cscli.Output == "raw")
104
105 err = plan.Execute(ctx, interactive, dryRun, showPlan, verbosePlan)
106 switch {
107 case errors.Is(err, hubops.ErrUserCanceled) && err != nil:
108 // not a real error, and we'll want to print the reload message anyway
109 fmt.Fprintln(os.Stdout, err.Error())
110 case err != nil:
111 return err
112 }
113
114 if msg := reload.UserMessage(); msg != "" && plan.ReloadNeeded {
115 fmt.Fprintln(os.Stdout, "\n"+msg)
116 }
117
118 return nil
119}
120
121func (cli *cliItem) newRemoveCmd() *cobra.Command {
122 var (

Callers 1

newRemoveCmdMethod · 0.95

Calls 7

removePlanMethod · 0.95
HubFunction · 0.92
UserMessageFunction · 0.92
cfgMethod · 0.80
StandardLoggerMethod · 0.80
ErrorMethod · 0.65
ExecuteMethod · 0.45

Tested by

no test coverage detected