Skip to content

Commit

Permalink
Upgrade to github.com/urfave/cli/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLindhout committed Feb 21, 2020
1 parent a53ce37 commit d8acf16
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 87 deletions.
14 changes: 9 additions & 5 deletions cmd/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ import (
"github.com/99designs/gqlgen/api"
"github.com/99designs/gqlgen/codegen/config"
"github.com/pkg/errors"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

var genCmd = cli.Command{
var genCmd = &cli.Command{
Name: "generate",
Usage: "generate a graphql server based on schema",
Flags: []cli.Flag{
cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
cli.StringFlag{Name: "config, c", Usage: "the config filename"},
&cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
&cli.StringFlag{Name: "config, c", Usage: "the config filename"},
},
Action: func(ctx *cli.Context) {
Action: func(ctx *cli.Context) error {
var cfg *config.Config
var err error
if configFilename := ctx.String("config"); configFilename != "" {
cfg, err = config.LoadConfig(configFilename)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
return err
}
} else {
cfg, err = config.LoadConfigFromDefaultLocations()
Expand All @@ -33,12 +34,15 @@ var genCmd = cli.Command{
} else if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(2)
return err
}
}

if err = api.Generate(cfg); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(3)
return err
}
return nil
},
}
15 changes: 8 additions & 7 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/99designs/gqlgen/codegen/config"
"github.com/99designs/gqlgen/internal/code"
"github.com/99designs/gqlgen/plugin/servergen"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

var configTemplate = template.Must(template.New("name").Parse(
Expand Down Expand Up @@ -105,16 +105,16 @@ type Mutation {
}
`

var initCmd = cli.Command{
var initCmd = &cli.Command{
Name: "init",
Usage: "create a new gqlgen project",
Flags: []cli.Flag{
cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
cli.StringFlag{Name: "config, c", Usage: "the config filename"},
cli.StringFlag{Name: "server", Usage: "where to write the server stub to", Value: "server.go"},
cli.StringFlag{Name: "schema", Usage: "where to write the schema stub to", Value: "graph/schema.graphqls"},
&cli.BoolFlag{Name: "verbose, v", Usage: "show logs"},
&cli.StringFlag{Name: "config, c", Usage: "the config filename"},
&cli.StringFlag{Name: "server", Usage: "where to write the server stub to", Value: "server.go"},
&cli.StringFlag{Name: "schema", Usage: "where to write the schema stub to", Value: "graph/schema.graphqls"},
},
Action: func(ctx *cli.Context) {
Action: func(ctx *cli.Context) error {
configFilename := ctx.String("config")
serverFilename := ctx.String("server")

Expand All @@ -130,6 +130,7 @@ var initCmd = cli.Command{
}

GenerateGraphServer(serverFilename)
return nil
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"

"github.com/99designs/gqlgen/graphql"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"

// Required since otherwise dep will prune away these unused packages before codegen has a chance to run
_ "github.com/99designs/gqlgen/graphql/handler"
Expand All @@ -32,7 +32,7 @@ func Execute() {
}

app.Action = genCmd.Action
app.Commands = []cli.Command{
app.Commands = []*cli.Command{
genCmd,
initCmd,
versionCmd,
Expand Down
7 changes: 4 additions & 3 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"fmt"

"github.com/99designs/gqlgen/graphql"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

var versionCmd = cli.Command{
var versionCmd = &cli.Command{
Name: "version",
Usage: "print the version string",
Action: func(ctx *cli.Context) {
Action: func(ctx *cli.Context) error {
fmt.Println(graphql.Version)
return nil
},
}
40 changes: 19 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
module github.com/99designs/gqlgen

go 1.12
go 1.13

require (
github.com/agnivade/levenshtein v1.0.3 // indirect
github.com/go-chi/chi v3.3.2+incompatible
github.com/gogo/protobuf v1.0.0 // indirect
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
github.com/gorilla/mux v1.6.1 // indirect
github.com/gorilla/websocket v1.2.0
github.com/hashicorp/golang-lru v0.5.0
github.com/go-chi/chi v4.0.3+incompatible
github.com/gogo/protobuf v1.3.1 // indirect
github.com/gorilla/mux v1.7.4 // indirect
github.com/gorilla/websocket v1.4.1
github.com/hashicorp/golang-lru v0.5.4
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381
github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007
github.com/matryer/moq v0.0.0-20200125112110-7615cbe60268
github.com/mattn/go-colorable v0.1.4
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047
github.com/mitchellh/mapstructure v1.1.2
github.com/opentracing/basictracer-go v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.0.2
github.com/pkg/errors v0.8.1
github.com/rs/cors v1.6.0
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371 // indirect
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0 // indirect
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.20.0
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e
github.com/opentracing/opentracing-go v1.1.0
github.com/pkg/errors v0.9.1
github.com/rs/cors v1.7.0
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect
github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd // indirect
github.com/stretchr/testify v1.5.1
github.com/urfave/cli/v2 v2.1.1
github.com/vektah/dataloaden v0.3.0
github.com/vektah/gqlparser/v2 v2.0.1
golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589
gopkg.in/yaml.v2 v2.2.4
sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755
golang.org/x/tools v0.0.0-20200220224806-8a925fa4c0df
gopkg.in/yaml.v2 v2.2.8
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 // indirect
)
Loading

0 comments on commit d8acf16

Please sign in to comment.