forked from Debian/dh-make-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clone.go
38 lines (31 loc) · 838 Bytes
/
clone.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"flag"
"fmt"
"log"
"os"
"os/exec"
)
func execClone(args []string) {
fs := flag.NewFlagSet("clone", flag.ExitOnError)
fs.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s clone <package-name>\n", os.Args[0])
fmt.Fprintf(os.Stderr, "Clone a Go package from Salsa\n"+
"and download the appropriate tarball.\n")
fmt.Fprintf(os.Stderr, "Example: %s clone golang-github-mmcdole-goxpp\n", os.Args[0])
}
err := fs.Parse(args)
if err != nil {
log.Fatalf("parse args: %s", err)
}
if fs.NArg() != 1 {
fs.Usage()
os.Exit(1)
}
cmd := exec.Command("gbp", "clone", fmt.Sprintf("vcsgit:%s", fs.Arg(0)), "--postclone=origtargz")
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
log.Fatalf("Could not run %v: %v", cmd.Args, err)
}
fmt.Printf("Successfully cloned %s\n", fs.Arg(0))
}