- Rewrite complet en Go : exe unique sans _internal/, sans extraction temp - GUI Windows-native via github.com/lxn/walk (TableView, TextEdit, PushButton) - Meme fonctionnalites : check repos, pull, checkout, auto-update, logs - build.bat : go build -ldflags "-H windowsgui -s -w" -> 9.6 Mo, zero dependance Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
1.6 KiB
Go
81 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
type RepoConfig struct {
|
|
Name string
|
|
URL string
|
|
Path string
|
|
}
|
|
|
|
type SelfUpdateConfig struct {
|
|
URL string
|
|
ExeName string
|
|
Branch string
|
|
}
|
|
|
|
func loadConfig() ([]RepoConfig, SelfUpdateConfig, error) {
|
|
cfgPath := filepath.Join(exeDir(), "config.ini")
|
|
f, err := os.Open(cfgPath)
|
|
if err != nil {
|
|
return nil, SelfUpdateConfig{}, err
|
|
}
|
|
defer f.Close()
|
|
|
|
var repos []RepoConfig
|
|
var su SelfUpdateConfig
|
|
section := ""
|
|
kv := map[string]string{}
|
|
|
|
flush := func() {
|
|
switch {
|
|
case strings.HasPrefix(section, "repo:"):
|
|
name := strings.TrimPrefix(section, "repo:")
|
|
if kv["url"] != "" && kv["path"] != "" {
|
|
repos = append(repos, RepoConfig{
|
|
Name: name,
|
|
URL: kv["url"],
|
|
Path: kv["path"],
|
|
})
|
|
}
|
|
case section == "self-update":
|
|
su.URL = strings.TrimRight(kv["url"], "/")
|
|
su.ExeName = kv["exe_name"]
|
|
if su.ExeName == "" {
|
|
su.ExeName = "GitUpdateChecker.exe"
|
|
}
|
|
su.Branch = kv["branch"]
|
|
if su.Branch == "" {
|
|
su.Branch = "master"
|
|
}
|
|
}
|
|
kv = map[string]string{}
|
|
}
|
|
|
|
scanner := bufio.NewScanner(f)
|
|
for scanner.Scan() {
|
|
line := strings.TrimSpace(scanner.Text())
|
|
if line == "" || strings.HasPrefix(line, ";") || strings.HasPrefix(line, "#") {
|
|
continue
|
|
}
|
|
if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") {
|
|
flush()
|
|
section = strings.ToLower(strings.TrimSpace(line[1 : len(line)-1]))
|
|
continue
|
|
}
|
|
if idx := strings.IndexByte(line, '='); idx > 0 {
|
|
k := strings.TrimSpace(strings.ToLower(line[:idx]))
|
|
v := strings.TrimSpace(line[idx+1:])
|
|
kv[k] = v
|
|
}
|
|
}
|
|
flush()
|
|
|
|
return repos, su, scanner.Err()
|
|
}
|