commit eda9f88
chld
·
2026-02-06 13:40:08 +0000 UTC
parent cf15f77
add noexut on 0, netter help, more idiot proofing
2 files changed,
+18,
-7
M
main.go
+3,
-1
1@@ -20,7 +20,9 @@ func Die(a string, b string, exit int) {
2 fmt.Printf("\033[m\033[31m%s: \033[1mERROR:\033[m ",
3 filepath.Base(os.Args[0]))
4 fmt.Printf("%s: %s\n", a, b)
5- os.Exit(exit)
6+ if exit != 0 {
7+ os.Exit(exit)
8+ }
9 }
10
11 func Warn(a string, b string) {
M
main.go
+15,
-6
1@@ -12,15 +12,19 @@ import (
2
3 func help() {
4 // ports management
5- fmt.Printf("%s ", filepath.Base(os.Args[0]))
6+ fmt.Printf("\033[m\033[1;31m%s\t\033[m\033[32m", filepath.Base(os.Args[0]))
7 fmt.Printf("[s]\n")
8 // package mamagement
9- fmt.Printf("%s ", filepath.Base(os.Args[0]))
10+ fmt.Printf("\033[m\033[1;32m%s\t\033[m\033[32m", filepath.Base(os.Args[0]))
11 fmt.Printf("[m|mi|mic]\n")
12
13 // package management without compiling
14- fmt.Printf("%s ", filepath.Base(os.Args[0]))
15- fmt.Printf("[sp]")
16+ fmt.Printf("\033[m\033[1;33m%s\t\033[m\033[32m", filepath.Base(os.Args[0]))
17+ fmt.Printf("[sp]\n")
18+
19+ // misc
20+ fmt.Printf("\033[m\033[1m%s\t\033[m\033[32m", filepath.Base(os.Args[0]))
21+ fmt.Printf("[h]")
22
23 fmt.Println()
24 }
25@@ -37,10 +41,10 @@ func main() {
26 switch act {
27 case "s":
28 dgr.Msg("cloning", "codeberg.org/derivelinux/ports")
29- os.RemoveAll("/ports")
30+ os.RemoveAll(os.Getenv("DTR_DIR"))
31
32 in, out := os.Stdin, os.Stdout
33- cmd := exec.Command("git", "clone", "--depth", "1", "https://codeberg.org/derivelinux/ports", "/ports")
34+ cmd := exec.Command("git", "clone", "--depth", "1", "https://codeberg.org/derivelinux/ports", os.Getenv("DTR_DIR"))
35 cmd.Stdin, cmd.Stdout = in, out // asign stdin and stdout to cmd
36 cmd.Stderr = os.Stderr // and stderr, i guess
37
38@@ -48,12 +52,14 @@ func main() {
39 dgr.Die("failed to clone", "codeberg.org/derivelinux/ports", 1)
40 }
41 case "c":
42+ dgre.VC("DTR_DIR")
43 if len(pkgs) < 1 {
44 help()
45 os.Exit(1)
46 }
47 dgrb.Build(pkgs[0], "clean")
48 case "m":
49+ dgre.VC("DTR_DIR")
50 dgrb.Build(pkgs[0], "build")
51 /*
52 case "mi":
53@@ -66,7 +72,10 @@ func main() {
54 case "sp":
55 dgre.VC("DTR_DIR")
56 fmt.Println(dgr.FindPkg(os.Args[2]))
57+ case "h", "help":
58+ help()
59 default:
60+ dgr.Die("unknown command", act, 0)
61 help()
62 }
63 }