Ejemplo n.º 1
0
func (command TagsCommand) listTagsForPaths(store *storage.Storage, paths []string) error {
	for _, path := range paths {
		if command.verbose {
			log.Infof("%v: retrieving tags.", path)
		}

		var tags, err = store.TagsForPath(path)
		if err != nil {
			log.Warn(err.Error())
			continue
		}

		if command.count {
			log.Print(path + ": " + strconv.Itoa(len(tags)))
		} else {
			log.Print(path + ": " + tagLine(tags))
		}
	}

	return nil
}
Ejemplo n.º 2
0
func (command TagsCommand) listTagsForWorkingDirectory(store *storage.Storage) error {
	file, err := os.Open(".")
	if err != nil {
		return fmt.Errorf("could not open working directory: %v", err)
	}
	defer file.Close()

	dirNames, err := file.Readdirnames(0)
	if err != nil {
		return fmt.Errorf("could not list working directory contents: %v", err)
	}

	sort.Strings(dirNames)

	for _, dirName := range dirNames {
		if command.verbose {
			log.Infof("%v: retrieving tags.", dirName)
		}

		var tags, err = store.TagsForPath(dirName)

		if err != nil {
			log.Warn(err.Error())
			continue
		}

		if len(tags) == 0 {
			continue
		}

		if command.count {
			log.Print(dirName + ": " + strconv.Itoa(len(tags)))
		} else {
			log.Print(dirName + ": " + tagLine(tags))
		}
	}

	return nil
}