mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-10-05 16:57:01 +08:00
29 lines
591 B
Go
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
|
|
}
|