Provide config with flags
Tim Izzo tim@5ika.ch
Mon, 21 Apr 2025 18:28:08 +0200
M
main.go
→
main.go
@@ -1,7 +1,10 @@
package main import ( + "flag" "fmt" + + "github.com/charmbracelet/log" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing/object"@@ -13,11 +16,13 @@ fmt.Printf("%s %s", style.date.Render(c.Author.When.Format(DATE_FORMAT)), c.Message)
} func main() { - url := "ssh://git.5ika.ch:1917/myglog" - path := "/tmp/glog" - repo, err := getRepo(url, path) - CheckIfError(err) + url := flag.String("url", "", "URL of the targeted git repository with logs") + path := flag.String("path", ".", "Path for the local git clone") + flag.Parse() + log.Info("Use " + *url + " cloned in " + *path) + repo, err := getRepo(*url, *path) + CheckIfError(err) ref, err := repo.Head() CheckIfError(err)