Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AwesomeGoCmd = &gcli.Command{ Name: "awesome", Desc: "view or search package on awesome go contents", Help: "contents from: " + awesomeCnUrl, Aliases: []string{"awe"}, Config: func(c *gcli.Command) { c.BoolOpt(&agOpts.cnDocs, "cn-doc", "cn", false, "the package contains Chinese readme") c.BoolOpt(&agOpts.update, "update", "up,u", false, "update the cached contents to latest") c.BoolOpt(&agOpts.active, "active", "", false, "the package status should be Active[update in the last week]") c.StrOpt2(&agOpts.lang, "lang,l", "language for the awesome-go contents, allow: en,zh-CN", func(opt *gflag.CliOpt) { opt.DefVal = "zh-CN" opt.Validator = func(val string) error { return errorx.IsIn(val, langs, "lang value must be in %v", langs) } }) c.IntOpt2(&agOpts.starMin, "star-min,min", "limit the min star number") c.IntOpt2(&agOpts.starMax, "star-max,max", "limit the max star number") c.IntOpt(&agOpts.limit, "limit", "size", 50, "limit the max package number") c.AddArg("keywords", "the keyword for search awesome-go contents", false, true) }, Func: func(c *gcli.Command, args []string) error { mkdownUrl := awesomeENTextUrl cacheFile := app.App().PathResolve("$tmp/awesome-go-cn.EN.md") if agOpts.lang == "zh-CN" { mkdownUrl = awesomeZHTextUrl cacheFile = app.App().PathResolve("$tmp/awesome-go-cn.zh-CN.md") } if agOpts.update || !fsutil.FileExists(cacheFile) { err := greq.MustDo("GET", mkdownUrl).SaveFile(cacheFile) if err != nil { return err } if agOpts.update { c.Infoln("update completed") return nil } } keywords := c.Arg("keywords").Strings() agOpts.keywords = append(keywords, "github.com") c.Infoln("Search package by keywords:", agOpts.keywords) c.Println("----------------------- RESULT ----------------------") var sb strings.Builder sb.Grow(512) var category string var n int s := fsutil.LineScanner(cacheFile) for s.Scan() { trimmed := strings.TrimSpace(s.Text()) if strings.HasPrefix(trimmed, "##") { category = trimmed } if !strings.HasPrefix(trimmed, "- ") { continue } if idx := strings.Index(trimmed, "[!["); idx > 0 { trimmed = trimmed[:idx] } if !textutil.IsMatchAll(trimmed, agOpts.keywords) { continue } starNum := getStarNum(trimmed) if agOpts.starMin > 0 && starNum < agOpts.starMin { continue } if agOpts.starMax > 0 && starNum > agOpts.starMax { continue } if category != "" { c.Warnln(category) category = "" } n++ fmt.Println(trimmed) if agOpts.limit > 0 && n >= agOpts.limit { break } } fmt.Println() c.Infoln("> Matched package result size:", n) return nil }, }
AwesomeGoCmd command
View Source
var GoInfoCmd = &gcli.Command{
Name: "info",
Desc: "system info for go",
}
GoInfoCmd refer https://github.com/lucor/goinfo
View Source
var GoToolsCmd = &gcli.Command{ Name: "go", Desc: "some go tools command", Subs: []*gcli.Command{ AwesomeGoCmd, ListBinCmd, GoInfoCmd, }, }
GoToolsCmd instance
View Source
var ListBinCmd = &gcli.Command{ Name: "list-bin", Desc: "start an php development server", Func: func(c *gcli.Command, args []string) error { c.Infoln("list bin in $GOPATH/bin") path := fsutil.ResolvePath("${GOPATH}/bin") cmd := cmdr.NewCmd("ls", path) return cmd.Run() }, }
ListBinCmd instance
Functions ¶
This section is empty.
Types ¶
type AwesomePkgInfo ¶
type AwesomePkgInfo struct { // GoDoc string // godoc document links CnDoc bool // Contains Chinese documents WeekActive bool // There was an update last week YearActive bool // It hasn't been updated in the last year Archived bool // The project has been archived }
AwesomePkgInfo struct
Click to show internal directories.
Click to hide internal directories.