Small re-organization of layout
14 files changed, 75 insertions(+), 75 deletions(-)

M cmd/tago/clear.go
M cmd/tago/db.go
M cmd/tago/delete.go
M cmd/tago/files.go
M cmd/tago/main.go
M cmd/tago/merge.go
M cmd/tago/search.go
M cmd/tago/stats.go
M cmd/tago/tag.go
M cmd/tago/tags.go
M lib/db.go => db.go
M lib/flags.go => flags.go
M lib/helpers.go => helpers.go
M lib/types.go => types.go
M cmd/tago/clear.go +9 -9
@@ 4,7 4,7 @@ import (
 	"fmt"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 39,15 39,15 @@ func init() {
 // ClearFiles remove all tags for given file
 func ClearFiles(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}
 	defer qm.DB.Close()
 
-	file := lib.NewFile(qm, args[0])
+	file := tago.NewFile(qm, args[0])
 	if err := file.Load(qm, false); err != nil {
-		if _, ok := err.(lib.NotFoundError); ok {
+		if _, ok := err.(tago.NotFoundError); ok {
 			fmt.Println(err.Error())
 			return nil
 		}

          
@@ 57,27 57,27 @@ func ClearFiles(cmd *cobra.Command, args
 	if err = file.Clear(qm); err != nil {
 		return err
 	}
-	fmt.Printf("Successfully cleared all tags for %s.\n", lib.RelativePath(file.FullPath()))
+	fmt.Printf("Successfully cleared all tags for %s.\n", tago.RelativePath(file.FullPath()))
 	return nil
 }
 
 // ClearTags remove all tag assignments for given tag
 func ClearTags(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}
 	defer qm.DB.Close()
 
-	if _, err := lib.ValidateTagName(args[0]); err != nil {
+	if _, err := tago.ValidateTagName(args[0]); err != nil {
 		fmt.Println(err)
 		return nil
 	}
 
-	tag := lib.Tag{Name: args[0]}
+	tag := tago.Tag{Name: args[0]}
 	if err := tag.Fetch(qm); err != nil {
-		if _, ok := err.(lib.NotFoundError); ok {
+		if _, ok := err.(tago.NotFoundError); ok {
 			fmt.Println(err.Error())
 			return nil
 		}

          
M cmd/tago/db.go +12 -12
@@ 6,7 6,7 @@ import (
 
 	_ "github.com/mattn/go-sqlite3" // sqlite3
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 43,11 43,11 @@ func init() {
 func DatabaseInit(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
 	force, _ := cmd.Flags().GetBool("force")
-	fpath := lib.GetFullFilePath(dbFile)
+	fpath := tago.GetFullFilePath(dbFile)
 	_, err := os.Stat(fpath)
 	if err != nil {
 		if os.IsNotExist(err) {
-			if err = lib.CreateDatabase(fpath); err != nil {
+			if err = tago.CreateDatabase(fpath); err != nil {
 				return err
 			}
 			return nil

          
@@ 58,10 58,10 @@ func DatabaseInit(cmd *cobra.Command, ar
 	fmt.Printf("Database file %v exists...\n", dbFile)
 	if force == true {
 		fmt.Println("Force flag is set, removing existing database file.")
-		if err = lib.BackupDatabase(fpath); err != nil {
+		if err = tago.BackupDatabase(fpath); err != nil {
 			return err
 		}
-		if err = lib.CreateDatabase(fpath); err != nil {
+		if err = tago.CreateDatabase(fpath); err != nil {
 			return err
 		}
 	} else {

          
@@ 73,7 73,7 @@ func DatabaseInit(cmd *cobra.Command, ar
 // UpgradeSchema upgrades db schema if needed
 func UpgradeSchema(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}

          
@@ 86,11 86,11 @@ func UpgradeSchema(cmd *cobra.Command, a
 		return fmt.Errorf("Unable to fetch schema version: %v", err)
 	}
 
-	if currentVersion < lib.SchemaVersion {
-		if err = lib.BackupDatabase(lib.GetFullFilePath(dbFile)); err != nil {
+	if currentVersion < tago.SchemaVersion {
+		if err = tago.BackupDatabase(tago.GetFullFilePath(dbFile)); err != nil {
 			return err
 		}
-		for currentVersion < lib.SchemaVersion {
+		for currentVersion < tago.SchemaVersion {
 			currentVersion++
 			switch currentVersion {
 			/* When changes are needed, something like:

          
@@ 102,10 102,10 @@ func UpgradeSchema(cmd *cobra.Command, a
 				fmt.Println("Schema version: ", currentVersion)
 			}
 			// Upgrade schema version after every iteration
-			lib.WriteSchemaVersion(qm.DB, currentVersion)
+			tago.WriteSchemaVersion(qm.DB, currentVersion)
 		}
 	} else {
-		fmt.Println("Your schema is at the current version: ", lib.SchemaVersion)
+		fmt.Println("Your schema is at the current version: ", tago.SchemaVersion)
 	}
 
 	return nil

          
@@ 116,7 116,7 @@ func UpgradeSchema(cmd *cobra.Command, a
 /*
 func upgradeSchemaToVersion2(qm *QueryManager) error {
 	// Placeholder until an upgrade is actually needed
-	// lib.WriteSchemaVersion
+	// tago.WriteSchemaVersion
 	return nil
 }
 */

          
M cmd/tago/delete.go +9 -9
@@ 4,7 4,7 @@ import (
 	"fmt"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 39,15 39,15 @@ func init() {
 // DeleteFiles deletes files from db
 func DeleteFiles(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}
 	defer qm.DB.Close()
 
-	file := lib.NewFile(qm, args[0])
+	file := tago.NewFile(qm, args[0])
 	if err := file.Load(qm, false); err != nil {
-		if _, ok := err.(lib.NotFoundError); ok {
+		if _, ok := err.(tago.NotFoundError); ok {
 			fmt.Println(err.Error())
 			return nil
 		}

          
@@ 57,27 57,27 @@ func DeleteFiles(cmd *cobra.Command, arg
 	if err = file.Delete(qm); err != nil {
 		return err
 	}
-	fmt.Printf("Successfully removed %s from the database.\n", lib.RelativePath(file.FullPath()))
+	fmt.Printf("Successfully removed %s from the database.\n", tago.RelativePath(file.FullPath()))
 	return nil
 }
 
 // DeleteTags deletes tags from db
 func DeleteTags(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}
 	defer qm.DB.Close()
 
-	if _, err := lib.ValidateTagName(args[0]); err != nil {
+	if _, err := tago.ValidateTagName(args[0]); err != nil {
 		fmt.Println(err)
 		return nil
 	}
 
-	tag := lib.Tag{Name: args[0]}
+	tag := tago.Tag{Name: args[0]}
 	if err := tag.Fetch(qm); err != nil {
-		if _, ok := err.(lib.NotFoundError); ok {
+		if _, ok := err.(tago.NotFoundError); ok {
 			fmt.Println(err.Error())
 			return nil
 		}

          
M cmd/tago/files.go +6 -6
@@ 4,7 4,7 @@ import (
 	"fmt"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 24,7 24,7 @@ func init() {
 func ListFiles(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
 	ctype, _ := cmd.Flags().GetString("ctype")
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}

          
@@ 32,7 32,7 @@ func ListFiles(cmd *cobra.Command, args 
 
 	vargs := make([]string, 0, len(args))
 	for _, arg := range args {
-		if tag, err := lib.ValidateTagName(arg); err != nil {
+		if tag, err := tago.ValidateTagName(arg); err != nil {
 			fmt.Println(err)
 		} else {
 			vargs = append(vargs, tag)

          
@@ 43,19 43,19 @@ func ListFiles(cmd *cobra.Command, args 
 		return fmt.Errorf("No valid tags were given")
 	}
 
-	conf := &lib.SearchFilesConfig{}
+	conf := &tago.SearchFilesConfig{}
 	conf.Tags = vargs
 	if ctype != "" {
 		conf.Ctype = ctype
 	}
 
-	files, err := lib.FileSearch(qm, conf)
+	files, err := tago.FileSearch(qm, conf)
 	if err != nil {
 		return err
 	}
 	if len(files) > 0 {
 		for _, file := range files {
-			fmt.Printf("%v\n", lib.RelativePath(file.FullPath()))
+			fmt.Printf("%v\n", tago.RelativePath(file.FullPath()))
 		}
 	} else {
 		fmt.Println("There are no files with the given tags and options.")

          
M cmd/tago/main.go +3 -3
@@ 4,7 4,7 @@ import (
 	"os"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 var (

          
@@ 20,8 20,8 @@ var rootCmd = &cobra.Command{
 	Short:   "Tag and index your system files.",
 	Long:    "Tag and index your system files.",
 	PersistentPreRun: func(cmd *cobra.Command, args []string) {
-		lib.TagoRunFlags.DbFile = dbFile
-		lib.TagoRunFlags.ShowFullPath = fullPath
+		tago.TagoRunFlags.DbFile = dbFile
+		tago.TagoRunFlags.ShowFullPath = fullPath
 	},
 }
 

          
M cmd/tago/merge.go +5 -5
@@ 4,7 4,7 @@ import (
 	"fmt"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 22,20 22,20 @@ func init() {
 // MergeTags merges all tags from old-tag into new-tag
 func MergeTags(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}
 	defer qm.DB.Close()
 
 	for _, arg := range args {
-		if _, err := lib.ValidateTagName(arg); err != nil {
+		if _, err := tago.ValidateTagName(arg); err != nil {
 			return fmt.Errorf(err.Error())
 		}
 	}
 
-	otag := lib.Tag{Name: args[0]}
-	ntag := lib.Tag{Name: args[1]}
+	otag := tago.Tag{Name: args[0]}
+	ntag := tago.Tag{Name: args[1]}
 
 	if err := ntag.Merge(qm, &otag); err != nil {
 		return err

          
M cmd/tago/search.go +6 -6
@@ 5,7 5,7 @@ import (
 
 	"github.com/google/shlex"
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 27,9 27,9 @@ func SearchFiles(cmd *cobra.Command, arg
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
 	ctype, _ := cmd.Flags().GetString("ctype")
 	ltags, _ := cmd.Flags().GetString("tags")
-	conf := &lib.SearchFilesConfig{Search: args[0]}
+	conf := &tago.SearchFilesConfig{Search: args[0]}
 
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}

          
@@ 45,7 45,7 @@ func SearchFiles(cmd *cobra.Command, arg
 		// Get tags
 		tags := make([]string, 0, len(ptags))
 		for _, arg := range ptags {
-			if tag, err := lib.ValidateTagName(arg); err != nil {
+			if tag, err := tago.ValidateTagName(arg); err != nil {
 				fmt.Println(err)
 			} else {
 				tags = append(tags, tag)

          
@@ 63,13 63,13 @@ func SearchFiles(cmd *cobra.Command, arg
 		conf.Ctype = ctype
 	}
 
-	files, err := lib.FileSearch(qm, conf)
+	files, err := tago.FileSearch(qm, conf)
 	if err != nil {
 		return err
 	}
 	if len(files) > 0 {
 		for _, file := range files {
-			fmt.Printf("%v\n", lib.RelativePath(file.FullPath()))
+			fmt.Printf("%v\n", tago.RelativePath(file.FullPath()))
 		}
 	} else {
 		fmt.Println("There are no files with the given query and options.")

          
M cmd/tago/stats.go +3 -3
@@ 6,7 6,7 @@ import (
 	"text/tabwriter"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 24,7 24,7 @@ func init() {
 // ListTags lists all tags in the database
 func ListTags(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}

          
@@ 43,7 43,7 @@ func ListTags(cmd *cobra.Command, args [
 		ORDER BY
 			file_count DESC, length(name), name`
 
-	var tags []lib.Tag
+	var tags []tago.Tag
 	err = qm.DB.Select(&tags, q)
 	if err != nil {
 		return err

          
M cmd/tago/tag.go +12 -12
@@ 5,7 5,7 @@ import (
 
 	"github.com/google/shlex"
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 41,7 41,7 @@ func TagFile(cmd *cobra.Command, args []
 	ltags, _ := cmd.Flags().GetString("tags")
 	desc, _ := cmd.Flags().GetString("desc")
 	index, _ := cmd.Flags().GetBool("index")
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}

          
@@ 49,12 49,12 @@ func TagFile(cmd *cobra.Command, args []
 
 	if ltags == "" {
 		// One file
-		tags := make([]lib.Tag, 0, len(args[1:]))
+		tags := make([]tago.Tag, 0, len(args[1:]))
 		for _, arg := range args[1:] {
-			if tag, err := lib.ValidateTagName(arg); err != nil {
+			if tag, err := tago.ValidateTagName(arg); err != nil {
 				fmt.Println(err)
 			} else {
-				tags = append(tags, lib.Tag{Name: tag})
+				tags = append(tags, tago.Tag{Name: tag})
 			}
 		}
 

          
@@ 62,7 62,7 @@ func TagFile(cmd *cobra.Command, args []
 			return fmt.Errorf("No valid tags were given")
 		}
 
-		files, err := lib.NewFiles(qm, args[0])
+		files, err := tago.NewFiles(qm, args[0])
 		if err != nil {
 			return err
 		}

          
@@ 81,7 81,7 @@ func TagFile(cmd *cobra.Command, args []
 			if err := file.Tag(qm, tags...); err != nil {
 				return err
 			}
-			fmt.Println(lib.RelativePath(file.FullPath()))
+			fmt.Println(tago.RelativePath(file.FullPath()))
 		}
 	} else {
 		// Potentially multiple files

          
@@ 91,12 91,12 @@ func TagFile(cmd *cobra.Command, args []
 		}
 
 		// Get tags
-		tags := make([]lib.Tag, 0, len(ptags))
+		tags := make([]tago.Tag, 0, len(ptags))
 		for _, arg := range ptags {
-			if tag, err := lib.ValidateTagName(arg); err != nil {
+			if tag, err := tago.ValidateTagName(arg); err != nil {
 				fmt.Println(err)
 			} else {
-				tags = append(tags, lib.Tag{Name: tag})
+				tags = append(tags, tago.Tag{Name: tag})
 			}
 		}
 

          
@@ 106,7 106,7 @@ func TagFile(cmd *cobra.Command, args []
 
 		// Tag each file
 		for _, arg := range args {
-			files, err := lib.NewFiles(qm, arg)
+			files, err := tago.NewFiles(qm, arg)
 			if err != nil {
 				return err
 			}

          
@@ 124,7 124,7 @@ func TagFile(cmd *cobra.Command, args []
 				if err := file.Tag(qm, tags...); err != nil {
 					return err
 				}
-				fmt.Println(lib.RelativePath(file.FullPath()))
+				fmt.Println(tago.RelativePath(file.FullPath()))
 			}
 		}
 	}

          
M cmd/tago/tags.go +6 -6
@@ 4,7 4,7 @@ import (
 	"fmt"
 
 	"github.com/spf13/cobra"
-	"hg.code.netlandish.com/~petersanchez/tago/lib"
+	"hg.code.netlandish.com/~petersanchez/tago"
 )
 
 func init() {

          
@@ 22,15 22,15 @@ func init() {
 // ShowFileTags shows tags assigned to given file
 func ShowFileTags(cmd *cobra.Command, args []string) error {
 	cmd.SilenceUsage = true // Usage is correct, don't show on errors
-	qm, err := lib.NewQueryManager()
+	qm, err := tago.NewQueryManager()
 	if err != nil {
 		return err
 	}
 	defer qm.DB.Close()
 
-	file := lib.NewFile(qm, args[0])
+	file := tago.NewFile(qm, args[0])
 	if err := file.Load(qm, false); err != nil {
-		if _, ok := err.(lib.NotFoundError); ok {
+		if _, ok := err.(tago.NotFoundError); ok {
 			fmt.Println(err.Error())
 			return nil
 		}

          
@@ 42,11 42,11 @@ func ShowFileTags(cmd *cobra.Command, ar
 	}
 
 	if len(tags) == 0 {
-		fmt.Printf("%v: File is not currently tagged.\n", lib.RelativePath(file.FullPath()))
+		fmt.Printf("%v: File is not currently tagged.\n", tago.RelativePath(file.FullPath()))
 		return nil
 	}
 
-	fmt.Println(lib.RelativePath(file.FullPath()) + ":")
+	fmt.Println(tago.RelativePath(file.FullPath()) + ":")
 	for _, tag := range tags {
 		fmt.Printf("\t%v\n", tag.Name)
 	}

          
M lib/db.go => db.go +1 -1
@@ 1,4 1,4 @@ 
-package lib
+package tago
 
 import (
 	"fmt"

          
M lib/flags.go => flags.go +1 -1
@@ 1,4 1,4 @@ 
-package lib
+package tago
 
 // CLIFlags are global flags set on the command line
 type CLIFlags struct {

          
M lib/helpers.go => helpers.go +1 -1
@@ 1,4 1,4 @@ 
-package lib
+package tago
 
 import (
 	"fmt"

          
M lib/types.go => types.go +1 -1
@@ 1,4 1,4 @@ 
-package lib
+package tago
 
 import (
 	"bytes"