repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
6be2726
parent
72f6af9
author
Eric Bower
date
2025-11-28 13:00:24 -0500 EST
fix(pipe): to topic fns should handle if user already incldued
1 files changed,  +18, -2
M pkg/apps/pipe/cli.go
+18, -2
 1@@ -49,10 +49,16 @@ func NewTabWriter(out io.Writer) *tabwriter.Writer {
 2 
 3 // scope topic to user by prefixing name.
 4 func toTopic(userName, topic string) string {
 5+	if strings.HasPrefix(topic, userName+"/") {
 6+		return topic
 7+	}
 8 	return fmt.Sprintf("%s/%s", userName, topic)
 9 }
10 
11 func toPublicTopic(topic string) string {
12+	if strings.HasPrefix(topic, "public/") {
13+		return topic
14+	}
15 	return fmt.Sprintf("public/%s", topic)
16 }
17 
18@@ -403,12 +409,17 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware {
19 				}
20 
21 				if !*clean {
22+					fmtTopic := topic
23+					if *access != "" {
24+						fmtTopic = fmt.Sprintf("%s/%s", userName, topic)
25+					}
26+
27 					_, _ = fmt.Fprintf(
28 						sesh,
29 						"subscribe to this channel:\n  ssh %s sub %s%s\n",
30 						toSshCmd(handler.Cfg),
31 						msgFlag,
32-						topic,
33+						fmtTopic,
34 					)
35 				}
36 
37@@ -684,12 +695,17 @@ func Middleware(handler *CliHandler) pssh.SSHServerMiddleware {
38 				}
39 
40 				if isCreator && !*clean {
41+					fmtTopic := topic
42+					if *access != "" {
43+						fmtTopic = fmt.Sprintf("%s/%s", userName, topic)
44+					}
45+
46 					_, _ = fmt.Fprintf(
47 						sesh,
48 						"subscribe to this topic:\n  ssh %s sub %s%s\n",
49 						toSshCmd(handler.Cfg),
50 						flagMsg,
51-						topic,
52+						fmtTopic,
53 					)
54 				}
55