1 Star 0 Fork 15

Soulless / go-package-plantuml

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.67 KB
一键复制 编辑 原始数据 按行查看 历史
Chy 提交于 2019-09-19 12:50 . OSCHINA -> GITEE
package main
import (
"fmt"
"gitee.com/jscode/go-package-plantuml/codeanalysis"
log "github.com/Sirupsen/logrus"
"github.com/jessevdk/go-flags"
"os"
"path"
"strings"
)
func main() {
log.SetLevel(log.InfoLevel)
var opts struct {
CodeDir string `long:"codedir" description:"要扫描的代码目录" required:"true"`
GopathDir string `long:"gopath" description:"GOPATH目录" required:"true"`
OutputFile string `long:"outputfile" description:"解析结果保存到该文件中" required:"true"`
IgnoreDirs []string `long:"ignoredir" description:"需要排除的目录,不需要扫描和解析"`
}
if len(os.Args) == 1 {
fmt.Println("使用例子\n" +
os.Args[0] + " --codedir /appdev/gopath/src/github.com/contiv/netplugin --gopath /appdev/gopath --outputfile /tmp/result")
os.Exit(1)
}
_, err := flags.ParseArgs(&opts, os.Args)
if err != nil {
os.Exit(1)
}
if opts.CodeDir == "" {
panic("代码目录不能为空")
os.Exit(1)
}
if opts.GopathDir == "" {
panic("GOPATH目录不能为空")
os.Exit(1)
}
if !strings.HasPrefix(opts.CodeDir, opts.GopathDir) {
panic(fmt.Sprintf("代码目录%s,必须是GOPATH目录%s的子目录", opts.CodeDir, opts.GopathDir))
os.Exit(1)
}
for _, dir := range opts.IgnoreDirs {
if !strings.HasPrefix(dir, opts.CodeDir) {
panic(fmt.Sprintf("需要排除的目录%s,必须是代码目录%s的子目录", dir, opts.CodeDir))
os.Exit(1)
}
}
config := codeanalysis.Config{
CodeDir: opts.CodeDir,
GopathDir: opts.GopathDir,
VendorDir: path.Join(opts.CodeDir, "vendor"),
IgnoreDirs: opts.IgnoreDirs,
}
result := codeanalysis.AnalysisCode(config)
result.OutputToFile("/tmp/uml.txt")
}
Wiki/文档工具
1
https://gitee.com/soullessz/go-package-plantuml.git
git@gitee.com:soullessz/go-package-plantuml.git
soullessz
go-package-plantuml
go-package-plantuml
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891