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