graphql-engine/cli/commands/root.go
Shahidh K Muhammed 330f90de40
add project flag, change persistentprerun to prerun (close #552) (#557)
### Description

Adds `--project` flag to the CLI and changes all `PersistentPreRuns` to `PreRuns`

What component does this PR affect? 

- [ ] Server
- [ ] Console
- [x] CLI
- [ ] Docs
- [ ] Community Content
- [ ] Build System

### Related Issue

#552
2018-09-27 19:27:17 +05:30

37 lines
931 B
Go

// Package commands contains the definition for all the commands present in
// Hasura CLI.
package commands
import (
"github.com/hasura/graphql-engine/cli"
"github.com/spf13/cobra"
)
// rootCmd is the main "hasura" command
var rootCmd = &cobra.Command{
Use: "hasura",
Short: "Hasura GraphQL Engine command line tool",
SilenceUsage: true,
SilenceErrors: true,
}
func init() {
ec := &cli.ExecutionContext{}
rootCmd.AddCommand(
NewInitCmd(ec),
NewConsoleCmd(ec),
NewMetadataCmd(ec),
NewMigrateCmd(ec),
NewVersionCmd(ec),
NewDocsCmd(ec),
)
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)")
}
// Execute executes the command and returns the error
func Execute() error {
return rootCmd.Execute()
}