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
- name: Build
id: build
run: go build -o ${{ matrix.ARTIFACT }}
run: go build -o ${{ matrix.ARTIFACT }} -ldflags="-X 'main.version= ${{ needs.release.outputs.version }}'"
env:
GOARCH: "amd64"
- name: Hash

11
main.go
View file

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