sway/run_command.go

18 lines
361 B
Go
Raw Normal View History

2023-10-07 16:53:14 +02:00
package sway
import (
"context"
2024-02-14 15:12:39 +01:00
"git.milar.in/milarin/slices"
2023-10-07 16:53:14 +02:00
)
2024-02-14 15:12:39 +01:00
func (c *Client) RunCommand(ctx context.Context, cmd string) ([]error, error) {
results, err := sendMessage[[]commandResult](c, 0, cmd)
if err != nil {
2024-02-14 15:12:39 +01:00
return nil, err
2023-10-07 16:53:14 +02:00
}
2024-02-14 15:12:39 +01:00
errors := slices.Map(slices.Filter(results, commandResult.HasError), commandResult.GetError)
return errors, nil
2023-10-07 16:53:14 +02:00
}