diff --git a/cmd/alias.go b/cmd/alias.go index e85ff66..b925a84 100644 --- a/cmd/alias.go +++ b/cmd/alias.go @@ -3,6 +3,8 @@ package cmd import ( "errors" "fmt" + "log" + "time" "github.com/spf13/cobra" @@ -42,7 +44,13 @@ avlpn or something smaller and use that to query pman`, if err != nil { return err } - + lastEdit := make(map[string]string) + lastEdit["lastWrite"] = fmt.Sprintf(time.Now().Format("02 Jan 06 15:04")) + err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket) + if err != nil { + log.Print(err) + return err + } return nil }, } diff --git a/cmd/delete.go b/cmd/delete.go index b759380..2f7ccac 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -3,6 +3,8 @@ package cmd import ( "errors" "fmt" + "log" + "time" "github.com/spf13/cobra" @@ -52,6 +54,13 @@ var delCmd = &cobra.Command{ if err != nil { return err } + lastEdit := make(map[string]string) + lastEdit["lastWrite"] = fmt.Sprintf(time.Now().Format("02 Jan 06 15:04")) + err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket) + if err != nil { + log.Print(err) + return err + } fmt.Printf("Successfully deleted %s from the db \n", projName) return nil }, diff --git a/cmd/root.go b/cmd/root.go index 4889b96..ffbf314 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,7 @@ const ( StatusBucket = "projects" ProjectPathBucket = "projectPaths" ProjectAliasBucket = "projectAliases" + ConfigBucket = "config" version = "1.0" ) diff --git a/cmd/set.go b/cmd/set.go index e72ad48..4ac54bd 100644 --- a/cmd/set.go +++ b/cmd/set.go @@ -3,6 +3,8 @@ package cmd import ( "errors" "fmt" + "log" + "time" "github.com/spf13/cobra" @@ -47,6 +49,15 @@ var setCmd = &cobra.Command{ fmt.Println("Error updating record : ", err) return err } + + lastEdit := make(map[string]string) + lastEdit["lastWrite"] = fmt.Sprintf(time.Now().Format("02 Jan 06 15:04")) + err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket) + if err != nil { + log.Print(err) + return err + } + fmt.Printf("Project %s set to status %s\n", pname, status) return nil }, diff --git a/pkg/indexer.go b/pkg/indexer.go index 685cba2..4e0d6b1 100644 --- a/pkg/indexer.go +++ b/pkg/indexer.go @@ -2,9 +2,11 @@ package pkg import ( "errors" + "fmt" "log" "os" "path/filepath" + "time" "github.com/theredditbandit/pman/pkg/db" ) @@ -14,6 +16,7 @@ const ( ProjectPaths = "projectPaths" ProjectAliasBucket = "projectAliases" LastUpdatedBucket = "lastUpdated" + ConfigBucket = "config" ) var ( @@ -61,6 +64,14 @@ func InitDirs(args []string) error { log.Print(err) return err } + lastEdit := make(map[string]string) + lastEdit["lastWrite"] = fmt.Sprintf(time.Now().Format("02 Jan 06 15:04")) + err = db.WriteToDB(db.DBName, lastEdit, ConfigBucket) + if err != nil { + log.Print(err) + return err + } + return nil }