Skip to content

Commit

Permalink
add version command
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskim06 committed Feb 23, 2023
1 parent f8dd448 commit ce9bb54
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ builds:
- darwin
goarch:
- amd64
ldflags:
- -s -w -X github.com/chriskim06/kubectl-topui/internal/cmd.tag={{.Version}}
archives:
- builds:
- kubectl-topui
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
go build -o out/kubectl-topui
go build -ldflags "-s -w -X github.com/chriskim06/kubectl-topui/internal/cmd.tag=DEV" -o out/kubectl-topui

clean:
rm -r out
1 change: 0 additions & 1 deletion internal/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Keyboard Shortcuts:
- q: quit
- j: scroll down
- k: scroll up
- ?: display help modal
- enter: view spec for selected item`
)

Expand Down
40 changes: 40 additions & 0 deletions internal/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright © 2020 Chris Kim
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

var (
// set by goreleaser via ldflags
tag string

versionCmd = &cobra.Command{
Use: "version",
Short: "Show topui version",
RunE: func(_ *cobra.Command, args []string) error {
fmt.Printf("v%s\n", tag)
return nil
},
}
)

func init() {
rootCmd.AddCommand(versionCmd)
}

0 comments on commit ce9bb54

Please sign in to comment.