-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (47 loc) · 1.22 KB
/
main.go
File metadata and controls
57 lines (47 loc) · 1.22 KB
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
package main
import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/mattn/go-runewidth"
"github.com/mritd/gitflow-toolkit/v3/cmd"
"github.com/mritd/gitflow-toolkit/v3/consts"
)
var (
version = "dev"
buildDate = "unknown"
commit = "unknown"
)
func main() {
// Detect invocation name for git subcommand support
binName := detectBinaryName()
// Handle git subcommand invocations (e.g., git-ci -> ci)
if strings.HasPrefix(binName, consts.GitCommandPrefix) {
subCmd := strings.TrimPrefix(binName, consts.GitCommandPrefix)
os.Args = append([]string{os.Args[0], subCmd}, os.Args[1:]...)
}
// Set version info
cmd.SetVersionInfo(cmd.VersionInfo{
Version: version,
Commit: commit,
BuildDate: buildDate,
GoVersion: runtime.Version(),
Platform: runtime.GOOS + "/" + runtime.GOARCH,
})
// Execute
cmd.Execute()
}
// detectBinaryName returns the base name of the executed binary.
func detectBinaryName() string {
bin, err := exec.LookPath(os.Args[0])
if err != nil {
return filepath.Base(os.Args[0])
}
return filepath.Base(bin)
}
// See: https://github.com/charmbracelet/lipgloss/issues/40#issuecomment-891167509
func init() {
runewidth.DefaultCondition.EastAsianWidth = false
}