1 Star 3 Fork 1

Joshua Conero/uymas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bin.go 899 Bytes
一键复制 编辑 原始数据 按行查看 历史
// @Date: 2018/10/30 0030 13:20
// @Author: Joshua Conero
// Package bin is sample command application lib, provides functional and classic style Apis.
package bin
import (
"regexp"
"strings"
)
const (
AppMethodInit = "Init"
AppMethodRun = "Run"
AppMethodNoSubC = "SubCommandUnfind"
AppMethodHelp = "Help"
FuncRegisterEmpty = "_inner_empty_func"
)
type initIota int
// the Cmd of type
const (
CmdApp initIota = iota
CmdFunc
)
// Cmd2StringMap command string turn to map string, for standard go method name.
// like:
//
// `get-videos` -> `GetVideos`
// `get_videos` -> `GetVideos`
func Cmd2StringMap(c string) string {
reg := regexp.MustCompile(`([-_]+)|(\s{2,})`)
c = reg.ReplaceAllString(c, " ")
var words []string
for _, v := range strings.Split(c, " ") {
if v != "" {
words = append(words, strings.Title(v))
}
}
return strings.Join(words, "")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/conero/uymas.git
git@gitee.com:conero/uymas.git
conero
uymas
uymas
v1.4.0-alpha.1

搜索帮助

D67c1975 1850385 1daf7b77 1850385