blob: a69973ae4fedcd3b7ff21a1086a06a37771e50b3 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
"embed"
"os"
"unicode"
"go.wit.com/lib/gui/prep"
)
// sent via -ldflags
var VERSION string
var BUILDTIME string
// used for shell auto completion
var ARGNAME string = "wit" // todo: get this from $0 ?
//go:embed resources/*
var resources embed.FS
func main() {
me = new(mainType)
// autocomplete must be processed before there is anything sent to STDOUT or STDERR
me.sh = prep.Bash3(&argv) // add support for bash autocomplete with go-arg
me.homedir, _ = os.UserHomeDir() // store shortcut here todo: add better logic
if argv.Upgrade != nil {
doUpgrade()
okExit("")
}
if argv.Rdate != nil {
doRdate()
okExit("")
}
if argv.Build != nil {
doBuild()
okExit("")
}
if argv.Git != nil {
doGit()
okExit("")
}
if argv.Clone != nil {
doClone()
okExit("")
}
if argv.WITCOM {
doWITCOM()
okExit("")
}
if argv.Upgrade != nil {
doUpgrade()
}
if argv.Publish != nil {
if err := doPublish(); err != nil {
badExit(err)
}
okExit("")
}
if argv.Zoo != nil {
if areSuperuser() {
exitOnErrorRealtime([]string{"journalctl", "-n", "100", "-f", "_SYSTEMD_UNIT=zood.service"})
}
okExit("do something here")
}
okExit("do what?")
}
// this is dumb. sync this with go-deb
func trimNonNumericFromStart(s string) string {
for i, r := range s {
if unicode.IsDigit(r) {
return s[i:]
}
}
return ""
}
|