Skip to content

Commit

Permalink
add -a flag to sendcmd for sending too all clients and sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Sep 9, 2021
1 parent 74bc28a commit 38fd0e3
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions kks.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func main() {

sendCmd := flag.NewFlagSet("send", flag.ExitOnError)
sendBufferFlag := sendCmd.String("b", "", "send to specified buffer")
sendAllFlag := sendCmd.Bool("a", false, "send to all sessions and clients")

attachCmd := flag.NewFlagSet("attach", flag.ExitOnError)

Expand Down Expand Up @@ -178,13 +179,31 @@ func main() {
args := sendCmd.Args()
kakCommand := strings.Join(args, " ")

context, err := NewContext()
if err != nil {
log.Fatal(err)
}
if err := kak.Send(kakCommand, *sendBufferFlag, context.Session, context.Client); err != nil {
log.Fatal(err)
switch *sendAllFlag {
case true:
sessions, err := kak.List()
if err != nil {
log.Fatal(err)
}

for _, session := range sessions {
for _, client := range session.Clients {
if err := kak.Send(kakCommand, "", session.Name, client); err != nil {
log.Fatal(err)
}
}

}
case false:
context, err := NewContext()
if err != nil {
log.Fatal(err)
}
if err := kak.Send(kakCommand, *sendBufferFlag, context.Session, context.Client); err != nil {
log.Fatal(err)
}
}

}

if getCmd.Parsed() {
Expand Down

0 comments on commit 38fd0e3

Please sign in to comment.