mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
api format from stdin (#4772)
This commit is contained in:
@@ -42,8 +42,19 @@ var (
|
|||||||
func GoFormatApi(_ *cobra.Command, _ []string) error {
|
func GoFormatApi(_ *cobra.Command, _ []string) error {
|
||||||
var be errorx.BatchError
|
var be errorx.BatchError
|
||||||
if VarBoolUseStdin {
|
if VarBoolUseStdin {
|
||||||
if err := apiFormatReader(os.Stdin, VarStringDir, VarBoolSkipCheckDeclare); err != nil {
|
if env.UseExperimental() {
|
||||||
be.Add(err)
|
data, err := io.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
be.Add(err)
|
||||||
|
} else {
|
||||||
|
if err := apiF.Source(data, os.Stdout); err != nil {
|
||||||
|
be.Add(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := apiFormatReader(os.Stdin, VarStringDir, VarBoolSkipCheckDeclare); err != nil {
|
||||||
|
be.Add(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(VarStringDir) == 0 {
|
if len(VarStringDir) == 0 {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
"dir": "{{.goctl.api.dir}}",
|
"dir": "{{.goctl.api.dir}}",
|
||||||
"iu": "Ignore update",
|
"iu": "Ignore update",
|
||||||
"stdin": "Use stdin to input api doc content, press \"ctrl + d\" to send EOF",
|
"stdin": "Use stdin to input api doc content, press \"ctrl + d\" to send EOF",
|
||||||
"declare": "Use to skip check api types already declare"
|
"declare": "Use to skip check api types already declare, deprecated if goctl version >= 1.8.3"
|
||||||
},
|
},
|
||||||
"go": {
|
"go": {
|
||||||
"short": "Generate go files for provided api in api file",
|
"short": "Generate go files for provided api in api file",
|
||||||
|
|||||||
Reference in New Issue
Block a user