commit 2007bfb
chld
·
2026-02-07 03:20:08 +0000 UTC
parent 5d8f7fe
no more boilerplate
4 files changed,
+6,
-20
+2,
-3
1@@ -5,12 +5,11 @@ import (
2 "os/exec"
3 )
4
5-func Run(a ...string) error {
6+func Run(a string, b ...string) error {
7 in, out := os.Stdin, os.Stdout
8- cmd := exec.Command(a[0], a[1:]...)
9+ cmd := exec.Command(a, b[0:]...)
10 cmd.Stdin, cmd.Stdout = in, out // asign stdin and stdout to cmd
11 cmd.Stderr = os.Stderr // and stderr, i guess
12
13 return cmd.Run()
14-
15 }
M
main.go
+0,
-1
1@@ -6,7 +6,6 @@ import (
2 "git.sr.ht/~chld/dgr/extra"
3 "git.sr.ht/~chld/dgr/pkg"
4 "os"
5- "os/exec"
6 "path/filepath"
7 )
8
+2,
-8
1@@ -3,8 +3,6 @@ package dgrb
2 import (
3 "git.sr.ht/~chld/dgr/cmd"
4 //"git.sr.ht/~chld/dgr/extra"
5- "os"
6- "os/exec"
7 "path/filepath"
8 )
9
10@@ -17,12 +15,8 @@ func Build(pkg string, do string) {
11 dgr.Die("couldnt find package", pkg, 1)
12 }
13
14- in, out := os.Stdin, os.Stdout
15- cmd := exec.Command("sh", filepath.Join(pk, makefile), do)
16- cmd.Stdin, cmd.Stdout = in, out // asign stdin andS stout to cmd
17- cmd.Stderr = os.Stderr // and stderr, i guess
18-
19- if err := cmd.Run(); err != nil {
20+ err := dgr.Run("sh", filepath.Join(pk, makefile), do)
21+ if err != nil {
22 dgr.Die(do+" failed", pkg, 1)
23 }
24 }
+2,
-8
1@@ -5,13 +5,11 @@ import (
2 "git.sr.ht/~chld/dgr/cmd"
3 "io/fs"
4 "os"
5- "os/exec"
6 "path/filepath"
7 )
8
9 func Inst(pkg string) {
10
11- in, out := os.Stdin, os.Stdout
12 pkginst := filepath.Join("/var/tmp/dtr", "pkg-"+pkg+"-git") // hard code git for now
13 pk, err := filepath.Glob(pkginst + "/*")
14
15@@ -22,12 +20,8 @@ func Inst(pkg string) {
16 args := append([]string{"-r"}, pk...)
17 args = append(args, os.Getenv("DTR_ROOT"))
18
19- cmd := exec.Command("cp", args...)
20-
21- cmd.Stdin, cmd.Stdout = in, out // asign stdin and stdout to cmd
22- cmd.Stderr = os.Stderr // and stderr, i guess
23-
24- if err := cmd.Run(); err != nil {
25+ err = dgr.Run("cp", args...)
26+ if err != nil {
27 dgr.Die("failed to copy package files to root", os.Getenv("DTR_ROOT"), 1)
28 } else {
29 dgr.Msg("installing", pkg)