Skip to content

Commit ce9bb54

Browse files
committed
add version command
1 parent f8dd448 commit ce9bb54

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

.goreleaser.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ builds:
1010
- darwin
1111
goarch:
1212
- amd64
13+
ldflags:
14+
- -s -w -X github.com/chriskim06/kubectl-topui/internal/cmd.tag={{.Version}}
1315
archives:
1416
- builds:
1517
- kubectl-topui

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
go build -o out/kubectl-topui
2+
go build -ldflags "-s -w -X github.com/chriskim06/kubectl-topui/internal/cmd.tag=DEV" -o out/kubectl-topui
33

44
clean:
55
rm -r out

internal/cmd/util.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Keyboard Shortcuts:
2929
- q: quit
3030
- j: scroll down
3131
- k: scroll up
32-
- ?: display help modal
3332
- enter: view spec for selected item`
3433
)
3534

internal/cmd/version.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
Copyright © 2020 Chris Kim
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
package cmd
17+
18+
import (
19+
"fmt"
20+
21+
"github.com/spf13/cobra"
22+
)
23+
24+
var (
25+
// set by goreleaser via ldflags
26+
tag string
27+
28+
versionCmd = &cobra.Command{
29+
Use: "version",
30+
Short: "Show topui version",
31+
RunE: func(_ *cobra.Command, args []string) error {
32+
fmt.Printf("v%s\n", tag)
33+
return nil
34+
},
35+
}
36+
)
37+
38+
func init() {
39+
rootCmd.AddCommand(versionCmd)
40+
}

0 commit comments

Comments
 (0)