Przeglądaj źródła

Read repo path from the commandline

Default to `.`.
Lucas Stadler 8 lat temu
rodzic
commit
4370f7e953
1 zmienionych plików z 8 dodań i 2 usunięć
  1. 8 2
      quit.go

+ 8 - 2
quit.go

@ -6,6 +6,7 @@ import (
6 6
	"io"
7 7
	"log"
8 8
	"net/http"
9
	"os"
9 10
	"strings"
10 11
	"time"
11 12
@ -14,7 +15,12 @@ import (
14 15
)
15 16
16 17
func main() {
17
	repo, err := git.OpenRepository("/home/lu/t/libgit2")
18
	repoPath := "."
19
	if len(os.Args) > 1 {
20
		repoPath = os.Args[1]
21
	}
22
23
	repo, err := git.OpenRepository(repoPath)
18 24
	if err != nil {
19 25
		log.Fatal("opening repository: ", err)
20 26
	}
@ -22,7 +28,7 @@ func main() {
22 28
	http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
23 29
		buf := new(bytes.Buffer)
24 30
		err = repoTmpl.Execute(buf, map[string]interface{}{
25
			"RepoPath": "~/t/libgit2",
31
			"RepoPath": repoPath,
26 32
			"Repo":     NewFancyRepo(repo),
27 33
			"Style":    template.CSS(repoStyle),
28 34
		})