1package cmd
2
3import (
4 "fmt"
5 "io/ioutil"
6 "log"
7 "os"
8
9 "github.com/99designs/gqlgen/graphql"
10 "github.com/urfave/cli"
11
12 // Required since otherwise dep will prune away these unused packages before codegen has a chance to run
13 _ "github.com/99designs/gqlgen/handler"
14)
15
16func Execute() {
17 app := cli.NewApp()
18 app.Name = "gqlgen"
19 app.Usage = genCmd.Usage
20 app.Description = "This is a library for quickly creating strictly typed graphql servers in golang. See https://gqlgen.com/ for a getting started guide."
21 app.HideVersion = true
22 app.Flags = genCmd.Flags
23 app.Version = graphql.Version
24 app.Before = func(context *cli.Context) error {
25 if context.Bool("verbose") {
26 log.SetFlags(0)
27 } else {
28 log.SetOutput(ioutil.Discard)
29 }
30 return nil
31 }
32
33 app.Action = genCmd.Action
34 app.Commands = []cli.Command{
35 genCmd,
36 initCmd,
37 versionCmd,
38 }
39
40 if err := app.Run(os.Args); err != nil {
41 fmt.Fprint(os.Stderr, err.Error())
42 os.Exit(1)
43 }
44}