@@ -41,16 +41,21 @@ func Run(ctx context.Context) {
4141
4242 var err error
4343
44- if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "bossac" ) {
45- programmer = & bossac.Bossac {}
46- } else if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "avrdude" ) {
47- programmer = & avrdude.Avrdude {}
48- } else {
49- log .Fatal ("Programmer path not specified correctly, programmer path set to: " + ctx .ProgrammerPath )
44+ if ctx .ProgrammerPath != "" {
45+ if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "bossac" ) {
46+ programmer = & bossac.Bossac {}
47+ } else if strings .Contains (filepath .Base (ctx .ProgrammerPath ), "avrdude" ) {
48+ programmer = & avrdude.Avrdude {}
49+ } else {
50+ log .Fatal ("Programmer path not specified correctly, programmer path set to: " + ctx .ProgrammerPath )
51+ }
5052 }
5153
5254 if ctx .FWUploaderBinary != "" {
5355 log .Println ("Flashing firmware uploader nina" )
56+ if programmer == nil {
57+ log .Fatal ("ERROR: You must specify a programmer!" )
58+ }
5459 if ctx .BinaryToRestore == "" {
5560 ctx .BinaryToRestore , err = programmer .DumpAndFlash (& ctx , ctx .FWUploaderBinary )
5661 } else {
@@ -107,9 +112,12 @@ func Run(ctx context.Context) {
107112 }
108113
109114 if ctx .BinaryToRestore != "" {
110- log .Println ("Restoring previous sketch" )
111115 f .Close ()
112116
117+ log .Println ("Restoring previous sketch" )
118+ if programmer == nil {
119+ log .Fatal ("ERROR: You must specify a programmer!" )
120+ }
113121 if err := programmer .Flash (& ctx , ctx .BinaryToRestore ); err != nil {
114122 log .Fatal (err )
115123 }
0 commit comments