feat: switch version

This commit is contained in:
MJECloud 2020-11-20 01:53:09 +01:00 committed by Jan De Dobbeleer
parent 4fa9f01653
commit 45b50fba3b
2 changed files with 12 additions and 1 deletions

View file

@ -68,7 +68,7 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build - name: Build
id: build id: build
run: go build -o ${{ matrix.ARTIFACT }} run: go build -o ${{ matrix.ARTIFACT }} -ldflags="-X 'main.version= ${{ needs.release.outputs.version }}'"
env: env:
GOARCH: "amd64" GOARCH: "amd64"
- name: Hash - name: Hash

11
main.go
View file

@ -7,6 +7,8 @@ import (
"fmt" "fmt"
) )
var currentVersion = "development"
type args struct { type args struct {
ErrorCode *int ErrorCode *int
PrintConfig *bool PrintConfig *bool
@ -14,6 +16,7 @@ type args struct {
Config *string Config *string
Shell *string Shell *string
PWD *string PWD *string
Version *bool
Debug *bool Debug *bool
} }
@ -43,6 +46,10 @@ func main() {
"pwd", "pwd",
"", "",
"the path you are working in"), "the path you are working in"),
Version: flag.Bool(
"version",
false,
"Print the current version of the binary"),
Debug: flag.Bool( Debug: flag.Bool(
"debug", "debug",
false, false,
@ -62,6 +69,10 @@ func main() {
fmt.Println(env.getShellName()) fmt.Println(env.getShellName())
return return
} }
if *args.Version {
fmt.Println(currentVersion)
return
}
colorWriter := &Renderer{ colorWriter := &Renderer{
Buffer: new(bytes.Buffer), Buffer: new(bytes.Buffer),
} }