@@ 2,6 2,8 @@ package cmd
import (
"fmt"
+ "os"
+ "text/tabwriter"
"github.com/spf13/cobra"
"hg.code.netlandish.com/~petersanchez/tago/lib"
@@ 47,11 49,13 @@ func ListTags(cmd *cobra.Command, args [
return err
}
if len(tags) > 0 {
- fmt.Println("Tag\t\tFile Count")
- fmt.Println("---\t\t----------")
+ writer := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', tabwriter.AlignRight)
+ fmt.Fprintln(writer, "Tag\tFile Count")
+ fmt.Fprintln(writer, "---\t----------")
for _, tag := range tags {
- fmt.Printf("%s\t\t%d\n", tag.Name, tag.Count)
+ fmt.Fprintf(writer, "%s\t\t%d\n", tag.Name, tag.Count)
}
+ writer.Flush()
} else {
fmt.Println("There are no tags in the database.")
}