@@ -8,13 +8,15 @@ import (
88
99 cmdApp "github.com/arduino/arduino-app-cli/cmd/arduino-app-cli/app"
1010 "github.com/arduino/arduino-app-cli/cmd/arduino-app-cli/completion"
11+ "github.com/arduino/arduino-app-cli/cmd/arduino-app-cli/internal/servicelocator"
1112 "github.com/arduino/arduino-app-cli/cmd/feedback"
1213 "github.com/arduino/arduino-app-cli/internal/orchestrator"
1314 "github.com/arduino/arduino-app-cli/internal/orchestrator/app"
1415 "github.com/arduino/arduino-app-cli/internal/orchestrator/config"
1516)
1617
1718func newCacheCleanCmd (cfg config.Configuration ) * cobra.Command {
19+ var forceClean bool
1820 appCmd := & cobra.Command {
1921 Use : "clean" ,
2022 Short : "Delete app cache" ,
@@ -26,16 +28,23 @@ func newCacheCleanCmd(cfg config.Configuration) *cobra.Command {
2628 if err != nil {
2729 return err
2830 }
29- return cacheCleanHandler (cmd .Context (), app )
31+ return cacheCleanHandler (cmd .Context (), app , forceClean )
3032 },
3133 ValidArgsFunction : completion .ApplicationNames (cfg ),
3234 }
35+ appCmd .Flags ().BoolVarP (& forceClean , "force" , "" , false , "Forcefully clean the cache even if the app is running" )
3336
3437 return appCmd
3538}
3639
37- func cacheCleanHandler (ctx context.Context , app app.ArduinoApp ) error {
38- if err := orchestrator .CleanAppCache (ctx , app ); err != nil {
40+ func cacheCleanHandler (ctx context.Context , app app.ArduinoApp , forceClean bool ) error {
41+ err := orchestrator .CleanAppCache (
42+ ctx ,
43+ servicelocator .GetDockerClient (),
44+ app ,
45+ orchestrator.CleanAppCacheRequest {ForceClean : forceClean },
46+ )
47+ if err != nil {
3948 feedback .Fatal (err .Error (), feedback .ErrGeneric )
4049 }
4150 feedback .PrintResult (cacheCleanResult {
0 commit comments