File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 5
5
"github.com/keenmate/db-gen/common"
6
6
dbGen "github.com/keenmate/db-gen/src"
7
7
"github.com/spf13/cobra"
8
+ "github.com/spf13/viper"
8
9
"log"
9
10
)
10
11
@@ -13,7 +14,16 @@ var generateCmd = &cobra.Command{
13
14
Short : "Generate code" ,
14
15
Long : "Generate code for calling database stored procedures" ,
15
16
Run : func (cmd * cobra.Command , args []string ) {
16
- err := doGenerate ()
17
+ configLocation := viper .GetString ("config" )
18
+
19
+ _ , err := dbGen .ReadConfig (configLocation )
20
+ if err != nil {
21
+ dbGen .Exit ("configuration error: %s" , err )
22
+ }
23
+
24
+ viper .AutomaticEnv () // read in environment variables that match
25
+
26
+ err = doGenerate ()
17
27
if err != nil {
18
28
dbGen .Exit (err .Error ())
19
29
}
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package cmd
3
3
import (
4
4
dbGen "github.com/keenmate/db-gen/src"
5
5
"github.com/spf13/cobra"
6
- "github.com/spf13/viper"
7
6
"os"
8
7
)
9
8
@@ -45,12 +44,5 @@ func init() {
45
44
46
45
// initConfig reads in config file and ENV variables if set.
47
46
func initConfig () {
48
- configLocation := viper .GetString ("config" )
49
47
50
- _ , err := dbGen .ReadConfig (configLocation )
51
- if err != nil {
52
- dbGen .Exit ("configuration error: %s" , err )
53
- }
54
-
55
- viper .AutomaticEnv () // read in environment variables that match
56
48
}
You can’t perform that action at this time.
0 commit comments