forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
32 lines (27 loc) · 765 Bytes
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Package cmd provides functionally common to various argo CLIs
package cmd
import (
"fmt"
"os"
"github.com/argoproj/argo"
"github.com/spf13/cobra"
)
// NewVersionCmd returns a new `version` command to be used as a sub-command to root
func NewVersionCmd(cliName string) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: fmt.Sprintf("Print version information"),
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s version %s\n", cliName, argo.FullVersion)
},
}
}
// MustIsDir returns whether or not the given filePath is a directory. Exits if path does not exist
func MustIsDir(filePath string) bool {
fileInfo, err := os.Stat(filePath)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
return fileInfo.IsDir()
}