1 Star 0 Fork 0

krypln / govendor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
shell.go 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Daniel Theophanes 提交于 2016-06-03 11:06 . run: remove unused comment
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package run
import (
"flag"
"fmt"
"io"
"os"
"github.com/kardianos/govendor/help"
"github.com/Bowery/prompt"
"github.com/google/shlex"
)
func (r *runner) Shell(w io.Writer, subCmdArgs []string) (help.HelpMessage, error) {
flags := flag.NewFlagSet("shell", flag.ContinueOnError)
flags.SetOutput(nullWriter{})
err := flags.Parse(subCmdArgs)
if err != nil {
return help.MsgShell, err
}
out := os.Stdout
for {
line, err := prompt.Basic("> ", false)
if err != nil {
break
}
args, err := shlex.Split(line)
if err != nil {
fmt.Fprintf(out, "%v", err.Error())
}
if len(args) == 0 {
continue
}
cmd := args[0]
next := make([]string, 0, len(args)+1)
next = append(next, "govendor")
args = append(next, args...)
switch cmd {
case "exit", "q", "quit", "/q":
return help.MsgNone, nil
case "shell":
continue
}
msg, err := r.run(out, args, nil)
if err != nil {
fmt.Fprintf(out, "%v", err.Error())
}
msgText := msg.String()
if len(msgText) > 0 {
fmt.Fprintf(out, "%s\tType \"exit\" to exit.\n", msgText)
}
}
return help.MsgNone, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/krypln/govendor.git
git@gitee.com:krypln/govendor.git
krypln
govendor
govendor
v1.0.5

搜索帮助

344bd9b3 5694891 D2dac590 5694891