本文整理汇总了Golang中github.com/github/hub/cmd.WithArg函数的典型用法代码示例。如果您正苦于以下问题:Golang WithArg函数的具体用法?Golang WithArg怎么用?Golang WithArg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WithArg函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: gitCmd
func gitCmd(args ...string) *cmd.Cmd {
cmd := cmd.New("git")
for _, v := range GlobalFlags {
cmd.WithArg(v)
}
for _, a := range args {
cmd.WithArg(a)
}
return cmd
}
示例2: Run
func Run(command string, args ...string) error {
cmd := cmd.New("git")
for _, v := range GlobalFlags {
cmd.WithArg(v)
}
cmd.WithArg(command)
for _, a := range args {
cmd.WithArg(a)
}
return cmd.Run()
}
示例3: Show
func Show(sha string) (string, error) {
cmd := cmd.New("git")
cmd.WithArg("show").WithArg("-s").WithArg("--format=%s%n%+b").WithArg(sha)
output, err := cmd.CombinedOutput()
output = strings.TrimSpace(output)
return output, err
}
示例4: gitOutput
func gitOutput(input ...string) (outputs []string, err error) {
cmd := cmd.New("git")
for _, v := range GlobalFlags {
cmd.WithArg(v)
}
for _, i := range input {
cmd.WithArg(i)
}
out, err := cmd.CombinedOutput()
for _, line := range strings.Split(out, "\n") {
line = strings.TrimSpace(line)
if line != "" {
outputs = append(outputs, string(line))
}
}
return outputs, err
}