@@ -95,15 +95,23 @@ func runUploadCommand(command *cobra.Command, args []string) {
9595 feedback .Fatal (tr ("Error during Upload: %v" , err ), feedback .ErrGeneric )
9696 }
9797
98- instance , profile := instance .CreateAndInitWithProfile (profileArg .Get (), sketchPath )
98+ var inst * rpc.Instance
99+ var profile * rpc.Profile
100+
101+ if profileArg .Get () == "" && fqbnArg .String () == "" {
102+ inst , profile = instance .CreateAndInitWithProfile (sk .Project .DefaultProfile , sketchPath , true )
103+ } else {
104+ inst , profile = instance .CreateAndInitWithProfile (profileArg .Get (), sketchPath , false )
105+ }
106+
99107 if fqbnArg .String () == "" {
100108 fqbnArg .Set (profile .GetFqbn ())
101109 }
102110
103- fqbn , port := arguments .CalculateFQBNAndPort (& portArgs , & fqbnArg , instance , sk )
111+ fqbn , port := arguments .CalculateFQBNAndPort (& portArgs , & fqbnArg , inst , sk )
104112
105113 userFieldRes , err := upload .SupportedUserFields (context .Background (), & rpc.SupportedUserFieldsRequest {
106- Instance : instance ,
114+ Instance : inst ,
107115 Fqbn : fqbn ,
108116 Protocol : port .Protocol ,
109117 })
@@ -120,7 +128,7 @@ func runUploadCommand(command *cobra.Command, args []string) {
120128 }
121129
122130 // FIXME: Here we must not access package manager...
123- pme , release := commands .GetPackageManagerExplorer (& rpc.UploadRequest {Instance : instance })
131+ pme , release := commands .GetPackageManagerExplorer (& rpc.UploadRequest {Instance : inst })
124132 platform := pme .FindPlatform (& packagemanager.PlatformReference {
125133 Package : split [0 ],
126134 PlatformArchitecture : split [1 ],
@@ -154,7 +162,7 @@ func runUploadCommand(command *cobra.Command, args []string) {
154162
155163 stdOut , stdErr , stdIOResult := feedback .OutputStreams ()
156164 req := & rpc.UploadRequest {
157- Instance : instance ,
165+ Instance : inst ,
158166 Fqbn : fqbn ,
159167 SketchPath : path ,
160168 Port : port ,
0 commit comments