repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
b2d8f18
parent
416b082
author
Antonio Mika
date
2024-09-10 23:17:08 +0000 UTC
Update cli
5 files changed,  +19, -21
M go.sum
M Dockerfile
+5, -5
 1@@ -1,4 +1,4 @@
 2-FROM --platform=$BUILDPLATFORM golang:1.22 as builder-deps
 3+FROM --platform=$BUILDPLATFORM golang:1.22 AS builder-deps
 4 LABEL maintainer="Pico Maintainers <hello@pico.sh>"
 5 
 6 WORKDIR /app
 7@@ -10,7 +10,7 @@ COPY go.* ./
 8 
 9 RUN go mod download
10 
11-FROM builder-deps as builder-web
12+FROM builder-deps AS builder-web
13 
14 COPY . .
15 
16@@ -25,7 +25,7 @@ ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
17 
18 RUN go build -ldflags "$LDFLAGS" -o /go/bin/${APP}-web ./cmd/${APP}/web
19 
20-FROM builder-deps as builder-ssh
21+FROM builder-deps AS builder-ssh
22 
23 COPY . .
24 
25@@ -40,7 +40,7 @@ ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
26 
27 RUN go build -ldflags "$LDFLAGS" -o /go/bin/${APP}-ssh ./cmd/${APP}/ssh
28 
29-FROM scratch as release-web
30+FROM scratch AS release-web
31 
32 WORKDIR /app
33 
34@@ -53,7 +53,7 @@ COPY --from=builder-web /app/${APP}/public ./${APP}/public
35 
36 ENTRYPOINT ["/app/web"]
37 
38-FROM scratch as release-ssh
39+FROM scratch AS release-ssh
40 
41 WORKDIR /app
42 ENV TERM="xterm-256color"
M bouncer/Dockerfile
+1, -1
1@@ -1,4 +1,4 @@
2-FROM golang:1.22-alpine as builder
3+FROM golang:1.22-alpine AS builder
4 
5 WORKDIR /app
6 
M go.sum
+0, -2
1@@ -226,8 +226,6 @@ github.com/picosh/go-rsync-receiver v0.0.0-20240709135253-1daf4b12a9fc h1:bvcsoO
2 github.com/picosh/go-rsync-receiver v0.0.0-20240709135253-1daf4b12a9fc/go.mod h1:i0iR3W4GSm1PuvVxB9OH32E5jP+CYkVb2NQSe0JCtlo=
3 github.com/picosh/pobj v0.0.0-20240709135546-27097077b26a h1:Cr1xODiyd/SjjBRtYA9VX6Do3D+w+DansQzkb4NGeyA=
4 github.com/picosh/pobj v0.0.0-20240709135546-27097077b26a/go.mod h1:VIkR1MZBvxSK2OO47jikxikAO/sKb/vTmXX5ZuYTIvo=
5-github.com/picosh/pubsub v0.0.0-20240909042445-92777a8b167b h1:/gGhT8y9rnrv8K9ZJKZYzdWvZcnazl8NGE1DGNrD8HU=
6-github.com/picosh/pubsub v0.0.0-20240909042445-92777a8b167b/go.mod h1:FKC8uot+40iXmuDzTfbxYDG5PIc3ghwkmP2iItBKH0I=
7 github.com/picosh/pubsub v0.0.0-20240910225407-529d97896161 h1:XKp88wHvv7YQXl4/BfnRCOLmcONTrJK2rE7XMr3gpdw=
8 github.com/picosh/pubsub v0.0.0-20240910225407-529d97896161/go.mod h1:vyHLOwIkdaBW+Wmc+3/yRzdnmKwv/oVnKtITHe46w58=
9 github.com/picosh/send v0.0.0-20240820031602-5d3b1a4494cc h1:IIsJuAFG2ju3cygKVKTIsYYZf21q5S3Dr1H4fGbfgJg=
M imgs/cli.go
+1, -1
1@@ -259,7 +259,7 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
2 				opts.bail(err)
3 				return
4 			} else if cmd == "sub" {
5-				err = pubsub.PubSub.Sub(fmt.Sprintf("%s@%s", user.Name, repoName), &psub.Sub{
6+				err = pubsub.PubSub.Sub(fmt.Sprintf("%s/%s", user.Name, repoName), &psub.Sub{
7 					ID:     uuid.NewString(),
8 					Writer: sesh,
9 					Done:   make(chan struct{}),
M pubsub/cli.go
+12, -12
 1@@ -60,11 +60,11 @@ func getUser(s ssh.Session, dbpool db.DB) (*db.User, error) {
 2 
 3 // scope channel to user by prefixing name.
 4 func toChannel(userName, name string) string {
 5-	return fmt.Sprintf("%s@%s", userName, name)
 6+	return fmt.Sprintf("%s/%s", userName, name)
 7 }
 8 
 9 func toPublicChannel(name string) string {
10-	return fmt.Sprintf("public@%s", name)
11+	return fmt.Sprintf("public/%s", name)
12 }
13 
14 var helpStr = `Commands: [pub, sub, ls]
15@@ -111,29 +111,29 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
16 				if cmd == "help" {
17 					wish.Println(sesh, helpStr)
18 				} else if cmd == "ls" {
19-					channels := pubsub.PubSub.GetChannels(fmt.Sprintf("%s@", user.Name))
20+					channels := pubsub.PubSub.GetChannels(fmt.Sprintf("%s/", user.Name))
21 
22 					if len(channels) == 0 {
23 						wish.Println(sesh, "no pubsub channels found")
24 					} else {
25-						outputData := "Channel Information\n"
26+						outputData := "Channel Information\r\n"
27 						for _, channel := range channels {
28-							outputData += fmt.Sprintf("- %s:\n", channel.Name)
29-							outputData += "\tPubs:\n"
30+							outputData += fmt.Sprintf("- %s:\r\n", channel.Name)
31+							outputData += "\tPubs:\r\n"
32 
33 							channel.Pubs.Range(func(I string, J *psub.Pub) bool {
34-								outputData += fmt.Sprintf("\t- %s:\n", I)
35+								outputData += fmt.Sprintf("\t- %s:\r\n", I)
36 								return true
37 							})
38 
39-							outputData += "\tSubs:\n"
40+							outputData += "\tSubs:\r\n"
41 
42 							channel.Subs.Range(func(I string, J *psub.Sub) bool {
43-								outputData += fmt.Sprintf("\t- %s:\n", I)
44+								outputData += fmt.Sprintf("\t- %s:\r\n", I)
45 								return true
46 							})
47 						}
48-						sesh.Write([]byte(outputData))
49+						_, _ = sesh.Write([]byte(outputData))
50 					}
51 				}
52 				next(sesh)
53@@ -173,7 +173,7 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
54 
55 				wish.Println(sesh, "sending msg ...")
56 				pub := &psub.Pub{
57-					ID:     uuid.NewString(),
58+					ID:     fmt.Sprintf("%s (%s@%s)", uuid.NewString(), user.Name, sesh.RemoteAddr().String()),
59 					Done:   make(chan struct{}),
60 					Reader: reader,
61 				}
62@@ -216,7 +216,7 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
63 				}
64 
65 				sub := &psub.Sub{
66-					ID:     uuid.NewString(),
67+					ID:     fmt.Sprintf("%s (%s@%s)", uuid.NewString(), user.Name, sesh.RemoteAddr().String()),
68 					Writer: sesh,
69 					Done:   make(chan struct{}),
70 					Data:   make(chan []byte),