Skip to content

Commit 3df5b6b

Browse files
rsoracmaglie
rsora
authored andcommitted
Restore -i shorthand flag for --input-file and add CLI checkFlagsConflicts function
1 parent bc86692 commit 3df5b6b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: cli/upload/upload.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,28 @@ func NewCommand() *cobra.Command {
4848
Long: "Upload Arduino sketches. This does NOT compile the sketch prior to upload.",
4949
Example: " " + os.Args[0] + " upload /home/user/Arduino/MySketch",
5050
Args: cobra.MaximumNArgs(1),
51+
PreRun: checkFlagsConflicts,
5152
Run: run,
5253
}
5354

5455
uploadCommand.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
5556
uploadCommand.Flags().StringVarP(&port, "port", "p", "", "Upload port, e.g.: COM10 or /dev/ttyACM0")
5657
uploadCommand.Flags().StringVarP(&importDir, "input-dir", "", "", "Directory containing binaries to upload.")
57-
uploadCommand.Flags().StringVarP(&importFile, "input-file", "", "", "Binary file to upload.")
58+
uploadCommand.Flags().StringVarP(&importFile, "input-file", "i", "", "Binary file to upload.")
5859
uploadCommand.Flags().BoolVarP(&verify, "verify", "t", false, "Verify uploaded binary after the upload.")
5960
uploadCommand.Flags().BoolVarP(&verbose, "verbose", "v", false, "Optional, turns on verbose mode.")
6061
uploadCommand.Flags().StringVarP(&programmer, "programmer", "P", "", "Optional, use the specified programmer to upload or 'list' to list supported programmers.")
6162

6263
return uploadCommand
6364
}
6465

66+
func checkFlagsConflicts(command *cobra.Command, args []string) {
67+
if importFile != "" && importDir != "" {
68+
feedback.Errorf("error: --input-file and --input-dir flags cannot be used together")
69+
os.Exit(errorcodes.ErrBadArgument)
70+
}
71+
}
72+
6573
func run(command *cobra.Command, args []string) {
6674
instance, err := instance.CreateInstance()
6775
if err != nil {

0 commit comments

Comments
 (0)