root cmd shows help and version

This commit is contained in:
Rick Olson 2014-06-26 15:14:11 -06:00
parent 4c2793165f
commit 9e95c6ef68
2 changed files with 10 additions and 2 deletions

@ -16,7 +16,14 @@ var (
)
func versionCommand(cmd *cobra.Command, args []string) {
Print("%s v%s", cmd.Parent().Name(), gitmedia.Version)
var parent *cobra.Command
if p := cmd.Parent(); p != nil {
parent = p
} else {
parent = cmd
}
Print("%s v%s", parent.Name(), gitmedia.Version)
if lovesComics {
Print("Nothing may see Gah Lak Tus and survive!")

@ -24,7 +24,8 @@ var (
Use: "git-media",
Short: "Git Media provides large file support to Git.",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Git Media, yo")
versionCommand(cmd, args)
cmd.Help()
},
}
)