Skip to content

Commit 17ced8f

Browse files
committed
Use internal function to check for arguments exclusivity
Because it has a better error message than the cobra-provided one: Can't use the following flags together: --quiet, --verbose Instead of: Error: if any flags in the group [quiet verbose] are set none of the others can be; [quiet verbose] were all set
1 parent c9122eb commit 17ced8f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/cli/compile/compile.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
8585
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property "build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n" +
8686
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property build.extra_flags=-DPIN=2 --build-property "compiler.cpp.extra_flags=\"-DSSID=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n",
8787
Args: cobra.MaximumNArgs(1),
88+
PreRun: func(cmd *cobra.Command, args []string) {
89+
arguments.CheckFlagsConflicts(cmd, "quiet", "verbose")
90+
},
8891
Run: func(cmd *cobra.Command, args []string) {
8992
if cmd.Flag("build-cache-path").Changed {
9093
feedback.Warning(i18n.Tr("The flag --build-cache-path has been deprecated. Please use just --build-path alone or configure the build cache path in the Arduino CLI settings."))
@@ -117,7 +120,6 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
117120
i18n.Tr(`Optional, can be: %s. Used to tell gcc which warning level to use (-W flag).`, "none, default, more, all"))
118121
compileCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, i18n.Tr("Optional, turns on verbose mode."))
119122
compileCommand.Flags().BoolVarP(&quiet, "quiet", "q", false, i18n.Tr("Optional, suppresses almost every output."))
120-
compileCommand.MarkFlagsMutuallyExclusive("quiet", "verbose")
121123
compileCommand.Flags().BoolVarP(&uploadAfterCompile, "upload", "u", false, i18n.Tr("Upload the binary after the compilation."))
122124
portArgs.AddToCommand(compileCommand, srv)
123125
compileCommand.Flags().BoolVarP(&verify, "verify", "t", false, i18n.Tr("Verify uploaded binary after the upload."))

0 commit comments

Comments
 (0)