Skip to content

Commit

Permalink
Merge pull request #87 from tobikris/fix-cli-gen-version
Browse files Browse the repository at this point in the history
fix cli version in generated file
  • Loading branch information
nikitawootten authored Feb 4, 2022
2 parents de64e97 + 563bb2e commit e7505e2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ USAGE:
gogmcli [global options] command [command options] [arguments...]
VERSION:
2.0.0
2.1.1
COMMANDS:
generate, g, gen to generate link and unlink functions for nodes
Expand Down
3 changes: 2 additions & 1 deletion cmd/gogmcli/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
// Generate searches for all go source files, then generates link and unlink functions for all gogm structs
// takes in root directory and whether to log in debug mode
// note: Generate is not recursive, it only looks in the target directory
func Generate(directory string, debug bool) error {
func Generate(directory string, debug bool, generator string) error {
confs := map[string][]*relConf{}
imps := map[string][]string{}
var edges []string
Expand Down Expand Up @@ -203,6 +203,7 @@ func Generate(directory string, debug bool) error {

buf := new(bytes.Buffer)
err = tpl.Execute(buf, templateConfig{
Generator: generator,
Imports: imports,
PackageName: packageName,
Funcs: funcs,
Expand Down
3 changes: 2 additions & 1 deletion cmd/gogmcli/gen/templ.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func(l *{{ .StructName }}) UnlinkFrom{{ .OtherStructName }}OnField{{.StructField
`

var masterTpl = `
{{ define "linkFile" }}// Code generated by GoGM v1.0.1. DO NOT EDIT
{{ define "linkFile" }}// Code generated by {{ .Generator }}. DO NOT EDIT
package {{ .PackageName }}
import (
Expand All @@ -279,6 +279,7 @@ import (
`

type templateConfig struct {
Generator string
Imports []string
PackageName string
// type: funcs
Expand Down
10 changes: 6 additions & 4 deletions cmd/gogmcli/gogm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ package main

import (
"errors"
"github.com/mindstand/gogm/v2/cmd/gogmcli/gen"
"github.com/urfave/cli/v2"
"fmt"
"log"
"os"

"github.com/mindstand/gogm/v2/cmd/gogmcli/gen"
"github.com/urfave/cli/v2"
)

//main is the main function
Expand All @@ -34,7 +36,7 @@ func main() {
app := &cli.App{
Name: "gogmcli",
HelpName: "gogmcli",
Version: "2.1.0",
Version: "2.1.1",
Usage: "used for neo4j operations from gogm schema",
Description: "cli for generating and executing migrations with gogm",
EnableBashCompletion: true,
Expand All @@ -58,7 +60,7 @@ func main() {
log.Printf("generating link and unlink from directory [%s]", directory)
}

return gen.Generate(directory, debug)
return gen.Generate(directory, debug, fmt.Sprintf("GoGM %s", c.App.Version))
},
},
},
Expand Down

0 comments on commit e7505e2

Please sign in to comment.