示例#1
0
func (command ImplyCommand) deleteImplication(store *storage.Storage, tagName, impliedTagName string) error {
	tag, err := store.Db.TagByName(tagName)
	if err != nil {
		return fmt.Errorf("could not retrieve tag '%v': %v", tagName, err)
	}
	if tag == nil {
		return fmt.Errorf("no such tag '%v'.", tagName)
	}

	impliedTag, err := store.Db.TagByName(impliedTagName)
	if err != nil {
		return fmt.Errorf("could not retrieve tag '%v': %v", impliedTagName, err)
	}
	if impliedTag == nil {
		return fmt.Errorf("no such tag '%v'.", impliedTagName)
	}

	if command.verbose {
		log.Infof("removing tag implication of '%v' to '%v'.", tagName, impliedTagName)
	}

	if err = store.RemoveImplication(tag.Id, impliedTag.Id); err != nil {
		return fmt.Errorf("could not add delete tag implication of '%v' to '%v': %v", tagName, impliedTagName, err)
	}

	return nil
}