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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
// An app to submit patches for the 30 GO GUI repos
import (
"embed"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
// sent via -ldflags // is there a better way?
var VERSION string
var BUILDTIME string
// at build time, this can be used to store GUI plugins with matching GO deps
//
//go:embed resources/*
var resources embed.FS
// used for shell auto completion
var ARGNAME string = "forge"
func main() {
me = new(mainType)
var s string
var err error
// autocomplete must run before everythingi
// any writes before this to STDOUT or STDERR
// will cause problems for the user at the command line
me.sh = prep.Autocomplete(&argv) // adds shell auto complete to go-args
// the current forge init process
me.forge, err = forgepb.Init() // init forge.pb
if err != nil {
s, err = doNewUser()
if err != nil {
me.sh.BadExit(s, err)
}
} else {
// do new user evertime for now
s, err = doNewUser()
if err != nil {
me.sh.BadExit(s, err)
}
}
// checks if this is a new forge setup.
// if so, forge needs to configure things first
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
if me.forge.Config.Mode != forgepb.ForgeMode_NORMAL {
me.forge.Config.DumpPB()
}
if me.forge.Config.Mode == forgepb.ForgeMode_DEVEL {
dumpDebug()
}
// if you are in "normal" mode, always run normal every time to catch accidental errors
// for example, if you accidentally changed branches from your user branch
if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL {
doNormal()
}
if me.sh.Cmd == "" {
s, err := doDefaultBehavior()
if err != nil {
me.sh.BadExit(s, err)
}
me.sh.GoodExit(s)
}
log.Info("Starting forge with subcommand:", me.sh.Cmd)
//// start standard argv subcommand processing here ////
if argv.Dev != nil {
// first find the repos or gopaths to operate on
if argv.Dev.Config != nil {
doConfig()
okExit("")
}
s, err := doDev()
if err != nil {
me.sh.BadExit(s, err)
}
me.sh.GoodExit(s)
}
if argv.Commit != nil {
s, err = doCommit()
}
if argv.Checkout != nil {
err = doCheckout()
}
if argv.Dev != nil {
s, err = doDev()
}
if argv.Fixer != nil {
s, err = doFix()
}
if argv.Clean != nil {
s, err = doClean()
}
if argv.Mode != nil {
s, err = doMode()
}
if argv.Normal != nil {
s, err = doNormal()
}
if argv.Merge != nil {
s, err = doMerge()
}
if argv.Add != nil {
doAdd()
}
if argv.Pull != nil {
doPull()
}
if argv.Show != nil {
s, err = doShow()
}
if argv.Patch != nil {
s, err = doPatch()
}
if argv.Whatchanged != nil {
// this might be deprecated by the git devs
// I put it here because of finger memory and it's nice
// for command line completion
r := shell.RunRealtime([]string{"bash", "-c", "git log"})
s = "git whatchanged is now: todo"
err = r.Error
}
if argv.Rebuild != nil {
// attempts to download all the sources
// and binaries needed to build forge
s, err = doRebuild()
}
if argv.Verify != nil {
s, err = doVerify()
}
//// end standard argv subcommand processing here ////
// if the gui starts, it doesn't yet go to the end normally
if argv.Gui != nil {
me.myGui.Start() // loads the GUI toolkit
doGui() // start making our forge GUI
debug() // sits here forever
}
// safe exits back to your shell (with timing and toolkit close)
if err != nil {
me.sh.BadExit(s, err)
}
me.sh.GoodExit(s)
}
|