Skip to content

Commit a6debf8

Browse files
committed
Removed globals in daemon command args parsing
1 parent ea09108 commit a6debf8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

internal/cli/daemon/daemon.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ import (
3434
"google.golang.org/grpc"
3535
)
3636

37-
var (
38-
daemonize bool
39-
debug bool
40-
debugFile string
41-
debugFilters []string
42-
)
43-
4437
// NewCommand created a new `daemon` command
4538
func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *cobra.Command {
39+
var daemonize bool
40+
var debug bool
41+
var debugFile string
42+
var debugFiltersArg []string
4643
var daemonPort string
4744
daemonCommand := &cobra.Command{
4845
Use: "daemon",
@@ -65,7 +62,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
6562
}
6663
},
6764
Run: func(cmd *cobra.Command, args []string) {
68-
runDaemonCommand(srv, daemonPort)
65+
runDaemonCommand(srv, daemonPort, debugFile, debug, daemonize, debugFiltersArg)
6966
},
7067
}
7168
defaultDaemonPort := settings.GetDaemon().GetPort()
@@ -82,13 +79,13 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
8279
daemonCommand.Flags().StringVar(&debugFile,
8380
"debug-file", "",
8481
i18n.Tr("Append debug logging to the specified file"))
85-
daemonCommand.Flags().StringSliceVar(&debugFilters,
82+
daemonCommand.Flags().StringSliceVar(&debugFiltersArg,
8683
"debug-filter", []string{},
8784
i18n.Tr("Display only the provided gRPC calls"))
8885
return daemonCommand
8986
}
9087

91-
func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort string) {
88+
func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort, debugFile string, debug, daemonize bool, debugFiltersArg []string) {
9289
logrus.Info("Executing `arduino-cli daemon`")
9390

9491
gRPCOptions := []grpc.ServerOption{}
@@ -113,6 +110,7 @@ func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort string) {
113110
debugStdOut = out
114111
}
115112
}
113+
debugFilters = debugFiltersArg
116114
gRPCOptions = append(gRPCOptions,
117115
grpc.UnaryInterceptor(unaryLoggerInterceptor),
118116
grpc.StreamInterceptor(streamLoggerInterceptor),

internal/cli/daemon/interceptors.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
var debugStdOut io.Writer
3030
var debugSeq uint32
31+
var debugFilters []string
3132

3233
func log(isRequest bool, seq uint32, msg interface{}) {
3334
prefix := fmt.Sprint(seq, " | ")

0 commit comments

Comments
 (0)