20 lines
508 B
Go
20 lines
508 B
Go
package sway
|
|
|
|
import (
|
|
"git.milar.in/milarin/slices"
|
|
)
|
|
|
|
// RunCommand runs all provided commands.
|
|
// It will return an array of errors
|
|
// which represent the result of each command.
|
|
// The last error is for communication problems only.
|
|
func (c *Client) RunCommand(cmd string) ([]error, error) {
|
|
results, err := sendMessage[[]commandResult](c, 0, cmd)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
errors := slices.Map(slices.Filter(results, commandResult.HasError), commandResult.GetError)
|
|
return errors, nil
|
|
}
|