cli: remove BeforeApply hooks and align command structs

This commit is contained in:
CrazyMax
2025-08-04 00:02:46 +02:00
parent 1d67f0703c
commit 0863995b1e
5 changed files with 72 additions and 73 deletions

View File

@@ -5,22 +5,30 @@ import (
"fmt"
"github.com/crazy-max/diun/v4/pb"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
// NotifCmd holds notif command
type NotifCmd struct {
Test NotifTestCmd `kong:"cmd,help='Test notification settings.'"`
Test NotifTestCmd `cmd:"" help:"Test notification settings."`
}
// NotifTestCmd holds notif test command
type NotifTestCmd struct {
CliGlobals
GRPCAuthority string `name:"grpc-authority" default:"127.0.0.1:42286" help:"Link to Diun gRPC server."`
}
func (s *NotifTestCmd) Run(_ *Context) error {
defer s.conn.Close()
conn, err := grpc.NewClient(s.GRPCAuthority, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
defer conn.Close()
nt, err := s.notifSvc.NotifTest(context.Background(), &pb.NotifTestRequest{})
notifSvc := pb.NewNotifServiceClient(conn)
nt, err := notifSvc.NotifTest(context.Background(), &pb.NotifTestRequest{})
if err != nil {
return err
}