1 Star 3 Fork 0

墨城/wait_cli

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wait_cli.go 1012 Bytes
一键复制 编辑 原始数据 按行查看 历史
qdmc 提交于 2021-09-02 14:58 +08:00 . project
/**
* Create by goland
* Author: 墨城
* Create Time: 2021-09-02 14:35
* Maintainers:
*/
package wait_cli
import (
"bufio"
"fmt"
"gitee.com/qdmc/wait_cli/cmd"
"gitee.com/qdmc/wait_cli/tools"
"github.com/spf13/cobra"
"os"
"strings"
)
func Start() {
runCmd := "wait_command"
for {
r := bufio.NewReader(os.Stdin)
res, err := r.ReadString('\n')
if err != nil {
fmt.Println("read is error....", err)
return
}
if strings.ToLower(tools.RemoveLBR(strings.Trim(res, " "))) == "exit" {
os.Exit(0)
}
os.Args = []string{
runCmd,
}
args := strings.Split(res, " ")
Args := []string{}
if len(args) >= 1 {
for _, a := range args {
arg := tools.RemoveLBR(strings.Trim(a, " "))
if arg != "" && arg != runCmd {
Args = append(Args, arg)
}
}
if len(Args) > 0 {
os.Args = append(os.Args, Args...)
} else {
os.Args = append(os.Args, "--help")
}
}
cmd.Execute()
}
}
func RegisterCmd(command *cobra.Command) {
cmd.RootCmd.AddCommand(command)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/qdmc/wait_cli.git
git@gitee.com:qdmc/wait_cli.git
qdmc
wait_cli
wait_cli
v1.1.1

搜索帮助