Skip to content

Commit 861d877

Browse files
committed
Added remove deps
1 parent 82c627a commit 861d877

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/cli/profile/profile_lib_remove.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,39 @@ import (
3434
func initLibRemoveCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
3535
var destDir string
3636
var profileArg arguments.Profile
37+
var noDeps bool
3738
removeCommand := &cobra.Command{
3839
Use: fmt.Sprintf("remove %s[@%s]...", i18n.Tr("LIBRARY"), i18n.Tr("VERSION_NUMBER")),
39-
Short: i18n.Tr("Removes a library from a sketch profile."),
40+
Short: i18n.Tr("Removes a library from a sketch profile with its dependencies if no longer needed."),
4041
Example: "" +
4142
" " + os.Args[0] + " profile lib remove AudioZero -m my_profile\n" +
4243
" " + os.Args[0] + " profile lib remove [email protected] --profile my_profile\n",
4344
Args: cobra.MinimumNArgs(1),
4445
Run: func(cmd *cobra.Command, args []string) {
45-
runLibRemoveCommand(cmd.Context(), srv, args, profileArg.Get(), destDir)
46+
runLibRemoveCommand(cmd.Context(), srv, args, profileArg.Get(), destDir, noDeps)
4647
},
4748
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
4849
return arguments.GetInstallableLibs(cmd.Context(), srv), cobra.ShellCompDirectiveDefault
4950
},
5051
}
5152
profileArg.AddToCommand(removeCommand, srv)
5253
removeCommand.Flags().StringVar(&destDir, "dest-dir", "", i18n.Tr("Location of the sketch project file."))
54+
removeCommand.Flags().BoolVar(&noDeps, "no-deps", false, i18n.Tr("Do not remove unused dependencies."))
5355
return removeCommand
5456
}
5557

56-
func runLibRemoveCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args []string, profile, destDir string) {
58+
func runLibRemoveCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args []string, profile, destDir string, noDeps bool) {
5759
sketchPath := arguments.InitSketchPath(destDir)
5860

5961
instance := instance.CreateAndInit(ctx, srv)
6062
libRefs, err := lib.ParseLibraryReferenceArgsAndAdjustCase(ctx, srv, instance, args)
6163
if err != nil {
6264
feedback.Fatal(i18n.Tr("Arguments error: %v", err), feedback.ErrBadArgument)
6365
}
66+
removeDeps := !noDeps
6467
for _, lib := range libRefs {
6568
resp, err := srv.ProfileLibRemove(ctx, &rpc.ProfileLibRemoveRequest{
69+
Instance: instance,
6670
SketchPath: sketchPath.String(),
6771
ProfileName: profile,
6872
Library: &rpc.ProfileLibraryReference{
@@ -73,6 +77,7 @@ func runLibRemoveCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer,
7377
},
7478
},
7579
},
80+
RemoveDependencies: &removeDeps,
7681
})
7782
if err != nil {
7883
feedback.Fatal(fmt.Sprintf("%s: %v",

0 commit comments

Comments
 (0)