aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/cmd/root.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-12-23 17:11:37 +0100
committerMichael Muré <batolettre@gmail.com>2018-12-23 17:11:37 +0100
commit1410a1af75b1ab9ea3f980a7e372728f9a123abf (patch)
treee24db8f84c48b20158b1f1fd6d281d700421279c /vendor/github.com/99designs/gqlgen/cmd/root.go
parent8fc15a032f021c855abf66ed303c003d57c340ea (diff)
downloadgit-bug-1410a1af75b1ab9ea3f980a7e372728f9a123abf.tar.gz
upgrade gqlgen to v0.7.1
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/cmd/root.go')
-rw-r--r--vendor/github.com/99designs/gqlgen/cmd/root.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/github.com/99designs/gqlgen/cmd/root.go b/vendor/github.com/99designs/gqlgen/cmd/root.go
new file mode 100644
index 00000000..519c2e1a
--- /dev/null
+++ b/vendor/github.com/99designs/gqlgen/cmd/root.go
@@ -0,0 +1,53 @@
+package cmd
+
+import (
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+
+ "github.com/99designs/gqlgen/graphql"
+ "github.com/99designs/gqlgen/internal/gopath"
+ "github.com/urfave/cli"
+
+ // Required since otherwise dep will prune away these unused packages before codegen has a chance to run
+ _ "github.com/99designs/gqlgen/handler"
+)
+
+func Execute() {
+ app := cli.NewApp()
+ app.Name = "gqlgen"
+ app.Usage = genCmd.Usage
+ app.Description = "This is a library for quickly creating strictly typed graphql servers in golang. See https://gqlgen.com/ for a getting started guide."
+ app.HideVersion = true
+ app.Flags = genCmd.Flags
+ app.Version = graphql.Version
+ app.Before = func(context *cli.Context) error {
+ pwd, err := os.Getwd()
+ if err != nil {
+ return fmt.Errorf("unable to determine current workding dir: %s\n", err.Error())
+ }
+
+ if !gopath.Contains(pwd) {
+ return fmt.Errorf("gqlgen must be run from inside your $GOPATH\n")
+ }
+ if context.Bool("verbose") {
+ log.SetFlags(0)
+ } else {
+ log.SetOutput(ioutil.Discard)
+ }
+ return nil
+ }
+
+ app.Action = genCmd.Action
+ app.Commands = []cli.Command{
+ genCmd,
+ initCmd,
+ versionCmd,
+ }
+
+ if err := app.Run(os.Args); err != nil {
+ fmt.Fprintf(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+}