graphql-engine/cli/commands/version.go
Aravind Shankar bb63d7e60e
cli: allow managing actions (#3859)
Co-authored-by: Rishichandra Wawhal <rishichandra.wawhal@gmail.com>
Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
Co-authored-by: Aravind <aravindkp@outlook.in>
Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
Co-authored-by: Shahidh K Muhammed <muhammedshahid.k@gmail.com>
2020-02-24 21:44:46 +05:30

33 lines
860 B
Go

package commands
import (
"github.com/hasura/graphql-engine/cli"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// NewVersionCmd returns the version command
func NewVersionCmd(ec *cli.ExecutionContext) *cobra.Command {
versionCmd := &cobra.Command{
Use: "version",
Short: "Print the CLI version",
SilenceUsage: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
ec.Viper = viper.New()
return ec.Prepare()
},
RunE: func(cmd *cobra.Command, args []string) error {
ec.Logger.WithField("version", ec.Version.GetCLIVersion()).Info("hasura cli")
err := ec.Validate()
if err == nil {
ec.Logger.
WithField("endpoint", ec.Config.ServerConfig.Endpoint).
WithField("version", ec.Version.GetServerVersion()).
Info("hasura graphql engine")
}
return nil
},
}
return versionCmd
}