@@ -34,6 +34,7 @@ import (
34
34
)
35
35
36
36
func initUpgradeCommand () * cobra.Command {
37
+ var postInstallFlags arguments.PostInstallFlags
37
38
upgradeCommand := & cobra.Command {
38
39
Use : fmt .Sprintf ("upgrade [%s:%s] ..." , tr ("PACKAGER" ), tr ("ARCH" )),
39
40
Short : tr ("Upgrades one or all installed platforms to the latest version." ),
@@ -43,16 +44,22 @@ func initUpgradeCommand() *cobra.Command {
43
44
" " + os .Args [0 ] + " core upgrade\n \n " +
44
45
" # " + tr ("upgrade arduino:samd to the latest version" ) + "\n " +
45
46
" " + os .Args [0 ] + " core upgrade arduino:samd" ,
46
- Run : runUpgradeCommand ,
47
+ Run : func (cmd * cobra.Command , args []string ) {
48
+ runUpgradeCommand (args , postInstallFlags .DetectSkipPostInstallValue ())
49
+ },
47
50
}
48
51
postInstallFlags .AddToCommand (upgradeCommand )
49
52
return upgradeCommand
50
53
}
51
54
52
- func runUpgradeCommand (cmd * cobra. Command , args []string ) {
55
+ func runUpgradeCommand (args []string , skipPostInstall bool ) {
53
56
inst := instance .CreateAndInit ()
54
57
logrus .Info ("Executing `arduino-cli core upgrade`" )
58
+ Upgrade (inst , args , skipPostInstall )
59
+ }
55
60
61
+ // Upgrade upgrades one or all installed platforms to the latest version.
62
+ func Upgrade (inst * rpc.Instance , args []string , skipPostInstall bool ) {
56
63
// if no platform was passed, upgrade allthethings
57
64
if len (args ) == 0 {
58
65
targets , err := core .GetPlatforms (& rpc.PlatformListRequest {
@@ -93,7 +100,7 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
93
100
Instance : inst ,
94
101
PlatformPackage : platformRef .PackageName ,
95
102
Architecture : platformRef .Architecture ,
96
- SkipPostInstall : postInstallFlags . DetectSkipPostInstallValue () ,
103
+ SkipPostInstall : skipPostInstall ,
97
104
}
98
105
99
106
if _ , err := core .PlatformUpgrade (context .Background (), r , output .ProgressBar (), output .TaskProgress ()); err != nil {
0 commit comments