Skip to content

Commit

Permalink
Add access list to ls output
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Nov 3, 2024
1 parent 590dffc commit 821e56d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pipe/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
if len(channels) > 0 || len(waitingChannels) > 0 {
outputData += "Channel Information\r\n"
for _, channel := range channels {
outputData += fmt.Sprintf("- %s:\r\n", channel.Topic)
extraData := ""

if accessList, ok := handler.Access.Load(channel.Topic); ok {
extraData += fmt.Sprintf(" (Access List: %s)", strings.Join(accessList, ", "))
}

outputData += fmt.Sprintf("- %s:%s\r\n", channel.Topic, extraData)
outputData += " Clients:\r\n"

var pubs []*psub.Client
Expand All @@ -232,7 +238,13 @@ func WishMiddleware(handler *CliHandler) wish.Middleware {
}

for waitingChannel, channelPubs := range waitingChannels {
outputData += fmt.Sprintf("- %s:\r\n", waitingChannel)
extraData := ""

if accessList, ok := handler.Access.Load(waitingChannel); ok {
extraData += fmt.Sprintf(" (Access List: %s)", strings.Join(accessList, ", "))
}

outputData += fmt.Sprintf("- %s:%s\r\n", waitingChannel, extraData)
outputData += " Clients:\r\n"
outputData += fmt.Sprintf(" %s:\r\n", "Waiting Pubs")
for _, client := range channelPubs {
Expand Down

0 comments on commit 821e56d

Please sign in to comment.