graphql-engine/cli/commands/root.go

37 lines
931 B
Go
Raw Normal View History

2018-06-27 15:04:09 +03:00
// Package commands contains the definition for all the commands present in
// Hasura CLI.
2018-06-24 16:40:48 +03:00
package commands
2018-06-24 16:47:01 +03:00
import (
"github.com/hasura/graphql-engine/cli"
"github.com/spf13/cobra"
)
2018-06-24 16:40:48 +03:00
2018-06-27 15:04:09 +03:00
// rootCmd is the main "hasura" command
2018-06-24 16:40:48 +03:00
var rootCmd = &cobra.Command{
Use: "hasura",
Short: "Hasura GraphQL Engine command line tool",
SilenceUsage: true,
SilenceErrors: true,
}
func init() {
2018-06-24 16:47:01 +03:00
ec := &cli.ExecutionContext{}
rootCmd.AddCommand(
NewInitCmd(ec),
NewConsoleCmd(ec),
NewMetadataCmd(ec),
NewMigrateCmd(ec),
NewVersionCmd(ec),
NewDocsCmd(ec),
2018-06-24 16:47:01 +03:00
)
f := rootCmd.PersistentFlags()
f.StringVar(&ec.LogLevel, "log-level", "INFO", "log level (DEBUG, INFO, WARN, ERROR, FATAL)")
f.StringVar(&ec.ExecutionDirectory, "project", "", "directory where commands are executed. (default: current dir)")
2018-06-24 16:40:48 +03:00
}
2018-06-27 15:04:09 +03:00
// Execute executes the command and returns the error
2018-06-24 16:40:48 +03:00
func Execute() error {
return rootCmd.Execute()
}