generator cleanup

Michael Muré created

Change summary

doc/gen_manpage.go          | 15 +++++++++++++--
doc/gen_markdown.go         | 20 ++++++++++++++++----
misc/gen_bash_completion.go |  7 ++++---
misc/gen_zsh_completion.go  |  3 ++-
misc/random_bugs/main.go    |  2 +-
5 files changed, 36 insertions(+), 11 deletions(-)

Detailed changes

doc/gen_manpage.go 🔗

@@ -7,6 +7,7 @@ import (
 	"log"
 	"os"
 	"path"
+	"path/filepath"
 
 	"github.com/MichaelMure/git-bug/commands"
 	"github.com/spf13/cobra/doc"
@@ -14,7 +15,7 @@ import (
 
 func main() {
 	cwd, _ := os.Getwd()
-	filepath := path.Join(cwd, "doc", "man")
+	dir := path.Join(cwd, "doc", "man")
 
 	header := &doc.GenManHeader{
 		Title:   "GIT-BUG",
@@ -24,7 +25,17 @@ func main() {
 
 	fmt.Println("Generating manpage ...")
 
-	err := doc.GenManTree(commands.RootCmd, header, filepath)
+	files, err := filepath.Glob(dir + "/*.1")
+	if err != nil {
+		log.Fatal(err)
+	}
+	for _, f := range files {
+		if err := os.Remove(f); err != nil {
+			log.Fatal(err)
+		}
+	}
+
+	err = doc.GenManTree(commands.RootCmd, header, dir)
 	if err != nil {
 		log.Fatal(err)
 	}

doc/gen_markdown.go 🔗

@@ -4,20 +4,32 @@ package main
 
 import (
 	"fmt"
-	"github.com/MichaelMure/git-bug/commands"
-	"github.com/spf13/cobra/doc"
 	"log"
 	"os"
 	"path"
+	"path/filepath"
+
+	"github.com/MichaelMure/git-bug/commands"
+	"github.com/spf13/cobra/doc"
 )
 
 func main() {
 	cwd, _ := os.Getwd()
-	filepath := path.Join(cwd, "doc", "md")
+	dir := path.Join(cwd, "doc", "md")
 
 	fmt.Println("Generating Markdown documentation ...")
 
-	err := doc.GenMarkdownTree(commands.RootCmd, filepath)
+	files, err := filepath.Glob(dir + "/*.md")
+	if err != nil {
+		log.Fatal(err)
+	}
+	for _, f := range files {
+		if err := os.Remove(f); err != nil {
+			log.Fatal(err)
+		}
+	}
+
+	err = doc.GenMarkdownTree(commands.RootCmd, dir)
 	if err != nil {
 		log.Fatal(err)
 	}

misc/gen_bash_completion.go 🔗

@@ -4,19 +4,20 @@ package main
 
 import (
 	"fmt"
-	"github.com/MichaelMure/git-bug/commands"
 	"log"
 	"os"
 	"path"
+
+	"github.com/MichaelMure/git-bug/commands"
 )
 
 func main() {
 	cwd, _ := os.Getwd()
-	filepath := path.Join(cwd, "misc", "bash_completion", "git-bug")
+	dir := path.Join(cwd, "misc", "bash_completion", "git-bug")
 
 	fmt.Println("Generating bash completion file ...")
 
-	err := commands.RootCmd.GenBashCompletionFile(filepath)
+	err := commands.RootCmd.GenBashCompletionFile(dir)
 	if err != nil {
 		log.Fatal(err)
 	}

misc/gen_zsh_completion.go 🔗

@@ -4,10 +4,11 @@ package main
 
 import (
 	"fmt"
-	"github.com/MichaelMure/git-bug/commands"
 	"log"
 	"os"
 	"path"
+
+	"github.com/MichaelMure/git-bug/commands"
 )
 
 func main() {

misc/random_bugs/main.go 🔗

@@ -17,7 +17,7 @@ func main() {
 		panic(err)
 	}
 
-	repo, err := repository.NewGitRepo(dir, func(repo *repository.GitRepo) error {
+	repo, err := repository.NewGitRepo(dir, func(repo repository.ClockedRepo) error {
 		return nil
 	})
 	if err != nil {