Files
cunicu/cmd/wicectl/shutdown.go
2022-01-06 15:11:25 +01:00

29 lines
591 B
Go

package main
import (
"context"
"fmt"
"github.com/spf13/cobra"
"riasc.eu/wice/pkg/pb"
)
var shutdownCmd = &cobra.Command{
Use: "shutdown",
Short: "Shutdown the WICE daemon",
RunE: shutdown,
PersistentPreRunE: pre,
PersistentPostRunE: post,
}
func shutdown(cmd *cobra.Command, args []string) error {
rerr, err := client.Shutdown(context.Background(), &pb.ShutdownParams{})
if err != nil {
return fmt.Errorf("failed RPC request: %w", err)
} else if !rerr.Ok() {
return fmt.Errorf("received RPC error: %w", rerr)
}
return nil
}