Skip to content

Commit e10d0ff

Browse files
author
rsora
committed
Restore -i shorthand flag for --input-file and add CLI checkFlagsConflicts function
1 parent 221df03 commit e10d0ff

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
@@ -49,20 +49,28 @@ func NewCommand() *cobra.Command {
4949
Long: "Upload Arduino sketches.",
5050
Example: " " + os.Args[0] + " upload /home/user/Arduino/MySketch",
5151
Args: cobra.MaximumNArgs(1),
52+
PreRun: checkFlagsConflicts,
5253
Run: run,
5354
}
5455

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

6364
return uploadCommand
6465
}
6566

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

0 commit comments

Comments
 (0)