本文整理匯總了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
}