feat: Replace cli to cobra (#1855)

* Replace cli

* Replace cli

* Replace cli

* Format code

* Add compare case

* Add compare case

* Add compare case

* Support go style flag

* Support go style flag

* Add test case
This commit is contained in:
anqiansong
2022-05-07 15:40:11 +08:00
committed by GitHub
parent 51472004a3
commit 5383e29ce6
61 changed files with 1858 additions and 1590 deletions

View File

@@ -7,19 +7,26 @@ import (
"path/filepath"
"strings"
"github.com/urfave/cli"
"github.com/spf13/cobra"
"github.com/zeromicro/go-zero/tools/goctl/api/parser"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
)
var (
// VarStringDir describes a directory.
VarStringDir string
// VarStringOutput describes an output directory.
VarStringOutput string
)
// DocCommand generate Markdown doc file
func DocCommand(c *cli.Context) error {
dir := c.String("dir")
func DocCommand(_ *cobra.Command, _ []string) error {
dir := VarStringDir
if len(dir) == 0 {
return errors.New("missing -dir")
}
outputDir := c.String("o")
outputDir := VarStringOutput
if len(outputDir) == 0 {
var err error
outputDir, err = os.Getwd()