mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
bb63d7e60e
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>
33 lines
860 B
Go
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
|
|
}
|