Skip to content

Commit

Permalink
'kubefwd version quiet' prints version only. This closes #88
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Nov 7, 2019
1 parent 963be3e commit 2d87e56
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/kubefwd/kubefwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ import (
var globalUsage = ``
var Version = "0.0.0"

func init() {
// quiet version
args := os.Args[1:]
if len(args) == 2 && args[0] == "version" && args[1] == "quiet" {
fmt.Println(Version)
os.Exit(0)
}
}

func newRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "kubefwd",
Expand All @@ -43,7 +52,9 @@ func newRootCmd() *cobra.Command {
versionCmd := &cobra.Command{
Use: "version",
Short: "Print the version of Kubefwd",
Long: ``,
Example: " kubefwd version\n" +
" kubefwd version quiet\n",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Kubefwd version: %s\nhttps://github.com/txn2/kubefwd\n", Version)
},
Expand All @@ -64,7 +75,6 @@ func (splitter *LogOutputSplitter) Write(p []byte) (n int, err error) {
}

func main() {

log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
ForceColors: true,
Expand Down

0 comments on commit 2d87e56

Please sign in to comment.