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

This commit is contained in:
he2ss 2021-12-30 11:32:05 +01:00 committed by GitHub
parent 9c8ca5c73a
commit ed38ca3a73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)