浏览代码

cscli: raise error on unknown collection remove (#1133)

he2ss 3 年之前
父节点
当前提交
ed38ca3a73
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      cmd/crowdsec-cli/collections.go

+ 3 - 0
cmd/crowdsec-cli/collections.go

@@ -76,6 +76,9 @@ func NewCollectionsCmd() *cobra.Command {
 				for _, name := range args {
 					if !forceAction {
 						item := cwhub.GetItem(cwhub.COLLECTIONS, name)
+						if item == nil {
+							log.Fatalf("unable to retrieve: %s\n", name)
+						}
 						if len(item.BelongsToCollections) > 0 {
 							log.Warningf("%s belongs to other collections :\n%s\n", name, item.BelongsToCollections)
 							log.Printf("Run 'sudo cscli collections remove %s --force' if you want to force remove this sub collection\n", name)