From f82ca7a951ef17e4ddb117d8715c7191c2f779b5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 22 Feb 2024 15:28:32 -0600 Subject: [PATCH] skip comments in config file --- Makefile | 2 +- flags.go | 20 ++++++++++++++++++++ listWindow.go | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 flags.go diff --git a/Makefile b/Makefile index 9ba7f03..2ac7baf 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: - @echo this is a go library, not a binary @GO111MODULE=off go build + @echo this is a go library with buildable code goimports: goimports -w *.go diff --git a/flags.go b/flags.go new file mode 100644 index 0000000..5ff1319 --- /dev/null +++ b/flags.go @@ -0,0 +1,20 @@ +package gowit + +/* + this enables command line options from other packages like 'gui' and 'log' +*/ + +import ( + "go.wit.com/log" +) + +var WIT *log.LogFlag +var WITWARN *log.LogFlag + +func init() { + full := "go.wit.com/lib/gui/gowit" + short := "gowit" + + WIT = log.NewFlag("WIT", true, full, short, "general go.wit.com things") + WITWARN = log.NewFlag("WITWARN", true, full, short, "wit.com warnings") +} diff --git a/listWindow.go b/listWindow.go index c69b759..61239b3 100644 --- a/listWindow.go +++ b/listWindow.go @@ -94,6 +94,15 @@ func ListWindow(view *repolist.RepoList) *gadgets.BasicWindow { currents = NewSection(group, "local (~/.config/myrepolist)") for i, line := range myrepolist() { + line = strings.TrimSpace(line) + if line == "" { + // skip blank lines + continue + } + if strings.HasPrefix(line, "#") { + // skip comment lines + continue + } parts := strings.Split(line, " ") log.Info("adding:", i, parts) currents.add(view, parts[0]) @@ -202,8 +211,12 @@ func (s *section) add(view *repolist.RepoList, path string) { log.Verbose("repo is already downloaded", path) tmp.downloadB.SetLabel("downloaded") tmp.downloadB.Disable() + s.grid.NewButton("Configure", func() { + log.Log(WIT, "todo: open the repo window here") + }) } + s.grid.NextRow() s.witRepos = append(s.witRepos, tmp) } @@ -228,7 +241,7 @@ func NewSection(parent *gui.Node, desc string) *section { } lw.Enable() }) - news.grid = news.parent.NewGrid("sections", 2, 1) + news.grid = news.parent.NewGrid("sections", 0, 0) allsections = append(allsections, news) return news }