Reorganization of command files
11 files changed, 22 insertions(+), 14 deletions(-)

M Makefile
M cmd/clear.go => cmd/tago/clear.go
M cmd/db.go => cmd/tago/db.go
M cmd/delete.go => cmd/tago/delete.go
M cmd/files.go => cmd/tago/files.go
M cmd/root.go => cmd/tago/main.go
M cmd/merge.go => cmd/tago/merge.go
M cmd/search.go => cmd/tago/search.go
M cmd/stats.go => cmd/tago/stats.go
M cmd/tag.go => cmd/tago/tag.go
M cmd/tags.go => cmd/tago/tags.go
M Makefile +9 -2
@@ 1,7 1,14 @@ 
+VERSION?=`hg log -r . -T "{latesttag}{sub('^-0-.*', '', '-{latesttagdistance}-m{node|short}')}" || echo 0.1.0`
+GO?=go
+GOFLAGS?=--tags="fts5"
+LDFLAGS+=-X main.Version=$(VERSION)
+
+GOSRC:=$(shell find ./cmd/tago/ -name '*.go')
+
 all: tago
 
-tago:
-	go build --tags="fts5" -o tago main.go
+tago: $(GOSRC)
+	$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $@ $(GOSRC)
 
 clean:
 	rm -f tago

          
M cmd/clear.go => cmd/tago/clear.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

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

          
M cmd/delete.go => cmd/tago/delete.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

          
M cmd/files.go => cmd/tago/files.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

          
M cmd/root.go => cmd/tago/main.go +4 -3
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"os"

          
@@ 10,6 10,8 @@ import (
 var (
 	dbFile   string
 	fullPath bool
+	// Version set at build time
+	Version string
 )
 
 var rootCmd = &cobra.Command{

          
@@ 34,8 36,7 @@ func init() {
 	)
 }
 
-// Execute main cobra caller
-func Execute() {
+func main() {
 	if err := rootCmd.Execute(); err != nil {
 		os.Exit(1)
 	}

          
M cmd/merge.go => cmd/tago/merge.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

          
M cmd/search.go => cmd/tago/search.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

          
M cmd/stats.go => cmd/tago/stats.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

          
M cmd/tag.go => cmd/tago/tag.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"

          
M cmd/tags.go => cmd/tago/tags.go +1 -1
@@ 1,4 1,4 @@ 
-package cmd
+package main
 
 import (
 	"fmt"