Skip to content

Commit

Permalink
chore(pubsub): print -p flag for pub and pipe stdout msg
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Oct 8, 2024
1 parent 62eeceb commit 6e77947
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pubsub/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,23 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
}

var name string
msgFlag := ""

if isAdmin && strings.HasPrefix(topic, "/") {
name = strings.TrimPrefix(topic, "/")
} else {
name = toTopic(user.Name, topic)
if *public {
name = toPublicTopic(topic)
msgFlag = "-p "
}
}

wish.Printf(
sesh,
"subscribe to this channel:\n\tssh %s sub %s\n",
"subscribe to this channel:\n\tssh %s sub %s%s\n",
toSshCmd(handler.Cfg),
msgFlag,
topic,
)

Expand Down Expand Up @@ -423,21 +426,24 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
}

var name string
flagMsg := ""

if isAdmin && strings.HasPrefix(topic, "/") {
name = strings.TrimPrefix(topic, "/")
} else {
name = toTopic(user.Name, topic)
if *public {
name = toPublicTopic(topic)
flagMsg = "-p "
}
}

if isCreator {
wish.Printf(
sesh,
"subscribe to this topic:\n\tssh %s sub %s\n",
"subscribe to this topic:\n\tssh %s sub %s%s\n",
toSshCmd(handler.Cfg),
flagMsg,
topic,
)
}
Expand Down

0 comments on commit 6e77947

Please sign in to comment.