summaryrefslogtreecommitdiff
path: root/repolist.go
blob: d199cd7df87f2fe01ef27b885eee679b62e8ade9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This is a simple example
package main

import 	(
	"io/ioutil"
	"strings"

	"go.wit.com/log"

	"go.wit.com/apps/control-panel-dns/smartwindow"
)

func (r *repo) getPath() string {
	return r.path
}

func RemoveFirstElement(slice []string) (string, []string) {
	if len(slice) == 0 {
		return "", slice // Return the original slice if it's empty
	}
	return slice[0], slice[1:] // Return the slice without the first element
}

// returns path, master branch name, devel branch name, user branch name
func splitLine(line string) (string, string, string, string) {
	var path, master, devel, user string
	parts := strings.Split(line, " ")
	path, parts = RemoveFirstElement(parts)
	master, parts = RemoveFirstElement(parts)
	devel, parts = RemoveFirstElement(parts)
	user, parts = RemoveFirstElement(parts)
	// path, master, devel, user := strings.Split(line, " ")
	return path, master, devel, user
}

// This creates a window
func hellosmart() {
	win := smartwindow.New()
	win.SetParent(myGui)
	win.InitWindow()
	win.Title("hellosmart test")
	win.Vertical()
	win.SetDraw(smartDraw)
	win.Make()

	win.Box().NewButton("test smartwindow", func () {
		log.Println("smart")
	})
}

func smartDraw(sw *smartwindow.SmartWindow) {
	sw.Box().NewButton("hello", func () {
		log.Println("smart")
	})
}

func myrepolist() []string {
	content, _ := ioutil.ReadFile("/home/jcarr/.config/myrepolist")
	out := string(content)
	out = strings.TrimSpace(out)
	lines := strings.Split(out, "\n")
	return lines
}