-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Kevin Wan <[email protected]>
- Loading branch information
Showing
12 changed files
with
572 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/zeromicro/go-zero/tools/goctl/internal/cobrax" | ||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx" | ||
) | ||
|
||
var ( | ||
// Cmd describes a bug command. | ||
Cmd = cobrax.NewCommand("config") | ||
|
||
initCmd = cobrax.NewCommand("init", cobrax.WithRunE(runConfigInit)) | ||
cleanCmd = cobrax.NewCommand("clean", cobrax.WithRunE(runConfigClean)) | ||
) | ||
|
||
func init() { | ||
Cmd.AddCommand(initCmd, cleanCmd) | ||
} | ||
|
||
func runConfigInit(*cobra.Command, []string) error { | ||
wd, err := os.Getwd() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfgFile, err := getConfigPath(wd) | ||
if err != nil { | ||
return err | ||
} | ||
if pathx.FileExists(cfgFile) { | ||
fmt.Printf("%s already exists, path: %s\n", configFile, cfgFile) | ||
return nil | ||
} | ||
|
||
err = os.WriteFile(cfgFile, defaultConfig, 0644) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("%s generated in %s\n", configFile, cfgFile) | ||
return nil | ||
} | ||
|
||
func runConfigClean(*cobra.Command, []string) error { | ||
wd, err := os.Getwd() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfgFile, err := getConfigPath(wd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return pathx.RemoveIfExist(cfgFile) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
model: | ||
types_map: | ||
bigint: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
dec: | ||
null_type: sql.NullFloat64 | ||
type: float64 | ||
decimal: | ||
null_type: sql.NullFloat64 | ||
type: float64 | ||
double: | ||
null_type: sql.NullFloat64 | ||
type: float64 | ||
float: | ||
null_type: sql.NullFloat64 | ||
type: float64 | ||
float4: | ||
null_type: sql.NullFloat64 | ||
type: float64 | ||
float8: | ||
null_type: sql.NullFloat64 | ||
type: float64 | ||
int: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
int1: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
int2: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
int3: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
int4: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
int8: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
integer: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
mediumint: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
middleint: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
smallint: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
tinyint: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
date: | ||
null_type: sql.NullTime | ||
type: time.Time | ||
datetime: | ||
null_type: sql.NullTime | ||
type: time.Time | ||
timestamp: | ||
null_type: sql.NullTime | ||
type: time.Time | ||
time: | ||
null_type: sql.NullString | ||
type: string | ||
year: | ||
null_type: sql.NullInt64 | ||
type: int64 | ||
unsigned_type: uint64 | ||
bit: | ||
null_type: sql.NullByte | ||
type: byte | ||
unsigned_type: byte | ||
bool: | ||
null_type: sql.NullBool | ||
type: bool | ||
boolean: | ||
null_type: sql.NullBool | ||
type: bool | ||
char: | ||
null_type: sql.NullString | ||
type: string | ||
varchar: | ||
null_type: sql.NullString | ||
type: string | ||
nvarchar: | ||
null_type: sql.NullString | ||
type: string | ||
nchar: | ||
null_type: sql.NullString | ||
type: string | ||
character: | ||
null_type: sql.NullString | ||
type: string | ||
longvarchar: | ||
null_type: sql.NullString | ||
type: string | ||
linestring: | ||
null_type: sql.NullString | ||
type: string | ||
multilinestring: | ||
null_type: sql.NullString | ||
type: string | ||
binary: | ||
null_type: sql.NullString | ||
type: string | ||
varbinary: | ||
null_type: sql.NullString | ||
type: string | ||
tinytext: | ||
null_type: sql.NullString | ||
type: string | ||
text: | ||
null_type: sql.NullString | ||
type: string | ||
mediumtext: | ||
null_type: sql.NullString | ||
type: string | ||
longtext: | ||
null_type: sql.NullString | ||
type: string | ||
enum: | ||
null_type: sql.NullString | ||
type: string | ||
set: | ||
null_type: sql.NullString | ||
type: string | ||
json: | ||
null_type: sql.NullString | ||
type: string | ||
blob: | ||
null_type: sql.NullString | ||
type: string | ||
longblob: | ||
null_type: sql.NullString | ||
type: string | ||
mediumblob: | ||
null_type: sql.NullString | ||
type: string | ||
tinyblob: | ||
null_type: sql.NullString | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.