commit 7ed9103
chld
·
2026-02-07 04:14:24 +0000 UTC
parent 98094cc
freedom in cmd/dialog.go and dependency sorting
3 files changed,
+28,
-6
+6,
-5
1@@ -4,16 +4,17 @@ import (
2 "fmt"
3 "os"
4 "path/filepath"
5+ "strings"
6 )
7
8-func Msg(a string, b string) {
9+func Msg(a ...string) {
10 fmt.Printf("\033[m\033[32;1m==>\033[m ")
11- fmt.Printf("%s: %s\n", a, b)
12+ fmt.Printf("%s\n", strings.Join(a, ""))
13 }
14
15-func Info(a string, b string) {
16- fmt.Printf("\033[m\033[1m)\t\033[m")
17- fmt.Printf("%s: %s\n", a, b)
18+func Info(a ...string) {
19+ fmt.Printf("\033[m\033[1m!=>\t\033[m")
20+ fmt.Printf("%s\n", strings.Join(a, ""))
21 }
22
23 func Die(a string, b string, exit int) {
A
go.sum
+2,
-0
1@@ -0,0 +1,2 @@
2+github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
3+github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
M
main.go
+20,
-1
1@@ -7,6 +7,7 @@ import (
2 "git.sr.ht/~chld/dgr/pkg"
3 "os"
4 "path/filepath"
5+ "strings"
6 )
7
8 func help() {
9@@ -21,7 +22,7 @@ func help() {
10
11 // package management without compiling
12 fmt.Printf("\033[m\033[1;33m%s\t\033[m\033[32m", filepath.Base(os.Args[0]))
13- fmt.Printf("[sp]")
14+ fmt.Printf("[sp|ld]")
15 fmt.Printf("\033[m\t\tmanage ports tree\n")
16
17 // misc
18@@ -50,6 +51,24 @@ func main() {
19 pkgs := os.Args[2:]
20
21 switch act {
22+ case "ld":
23+ dgr.Msg("dependencies of package ", pkgs[0], ":")
24+ x, _ := dgr.FindPkg(pkgs[0])
25+ file, _ := os.ReadFile(filepath.Join(x, "deps"))
26+
27+ f := strings.Fields(string(file))
28+ var a int
29+ for a < len(f) {
30+ if strings.Contains(f[a], ".") {
31+ fmt.Println(strings.ReplaceAll(f[a], ".", ""), "(build time)")
32+ } else if strings.Contains(f[a], "/") {
33+ fmt.Println(strings.ReplaceAll(f[a], "/", ""), "(link time)")
34+ } else if strings.Contains(f[a], ">") {
35+ fmt.Println(strings.ReplaceAll(f[a], ">", ""), "(runtime)")
36+ }
37+ a++
38+ continue
39+ }
40 case "s":
41 dgr.Msg("cloning", "codeberg.org/derivelinux/ports")
42 os.RemoveAll(os.Getenv("DTR_DIR"))