| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package scrpit
- import (
- "fmt"
- "log"
- "os"
- "os/exec"
- )
- // func main() {
- // exec.Command("git", "clone", "git@gitee.com:Anthony-Dong/template.git")
- //}
- func Git(str, dir string) {
- gitCmd := fmt.Sprintf("git clone %s %s", str, dir)
- Cmd(gitCmd)
- }
- func GitBranch(branch, str, dir string) {
- gitCmd := fmt.Sprintf("git clone -b %s %s %s", branch, str, dir)
- Cmd(gitCmd)
- }
- func Run(shell string) {
- gitCmd := fmt.Sprintf("%s", shell)
- Cmd(gitCmd)
- }
- func Copy(src, dest string) {
- gitCmd := fmt.Sprintf("cp %s %s", src, dest)
- Cmd(gitCmd)
- }
- func Mv(src, dest string) {
- gitCmd := fmt.Sprintf("mv %s %s", src, dest)
- Cmd(gitCmd)
- }
- // delete file
- func Delete(file string) {
- gitCmd := fmt.Sprintf("rm -rf %s", file)
- Cmd(gitCmd)
- }
- func Cmd(cmd string) {
- fmt.Println("/bin/bash " + "-c " + cmd)
- command := exec.Command("/bin/bash", "-c", cmd)
- command.Stdout = os.Stdout
- command.Stderr = os.Stdout
- err := command.Run()
- if err != nil {
- log.Fatal(fmt.Sprintf("run %s err", "/bin/bash "+"-c "+cmd))
- }
- }
|