@@ -46,9 +46,9 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
4646 resp , err := srv .ProfileLibAdd (ctx , & rpc.ProfileLibAddRequest {
4747 Instance : inst ,
4848 SketchPath : app .MainSketchPath .String (),
49- Library : & rpc.SketchProfileLibraryReference {
50- Library : & rpc.SketchProfileLibraryReference_IndexLibrary_ {
51- IndexLibrary : & rpc.SketchProfileLibraryReference_IndexLibrary {
49+ Library : & rpc.ProfileLibraryReference {
50+ Library : & rpc.ProfileLibraryReference_IndexLibrary_ {
51+ IndexLibrary : & rpc.ProfileLibraryReference_IndexLibrary {
5252 Name : libRef .Name ,
5353 Version : libRef .Version ,
5454 },
@@ -62,11 +62,11 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
6262 return f .Map (resp .GetAddedLibraries (), rpcProfileLibReferenceToLibReleaseID ), nil
6363}
6464
65- func RemoveSketchLibrary (ctx context.Context , app app.ArduinoApp , libRef LibraryReleaseID ) (LibraryReleaseID , error ) {
65+ func RemoveSketchLibrary (ctx context.Context , app app.ArduinoApp , libRef LibraryReleaseID , removeDeps bool ) ([] LibraryReleaseID , error ) {
6666 srv := commands .NewArduinoCoreServer ()
6767 var inst * rpc.Instance
6868 if res , err := srv .Create (ctx , & rpc.CreateRequest {}); err != nil {
69- return LibraryReleaseID {} , err
69+ return nil , err
7070 } else {
7171 inst = res .Instance
7272 }
@@ -77,23 +77,24 @@ func RemoveSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef Library
7777 // TODO: LOG progress/error?
7878 return nil
7979 })); err != nil {
80- return LibraryReleaseID {} , err
80+ return nil , err
8181 }
8282
8383 resp , err := srv .ProfileLibRemove (ctx , & rpc.ProfileLibRemoveRequest {
84- Library : & rpc.SketchProfileLibraryReference {
85- Library : & rpc.SketchProfileLibraryReference_IndexLibrary_ {
86- IndexLibrary : & rpc.SketchProfileLibraryReference_IndexLibrary {
84+ Library : & rpc.ProfileLibraryReference {
85+ Library : & rpc.ProfileLibraryReference_IndexLibrary_ {
86+ IndexLibrary : & rpc.ProfileLibraryReference_IndexLibrary {
8787 Name : libRef .Name ,
8888 },
8989 },
9090 },
91- SketchPath : app .MainSketchPath .String (),
91+ SketchPath : app .MainSketchPath .String (),
92+ RemoveDependencies : & removeDeps ,
9293 })
9394 if err != nil {
94- return LibraryReleaseID {} , err
95+ return nil , err
9596 }
96- return rpcProfileLibReferenceToLibReleaseID (resp .GetLibrary () ), nil
97+ return f . Map (resp .GetRemovedLibraries (), rpcProfileLibReferenceToLibReleaseID ), nil
9798}
9899
99100func ListSketchLibraries (ctx context.Context , app app.ArduinoApp ) ([]LibraryReleaseID , error ) {
@@ -107,19 +108,17 @@ func ListSketchLibraries(ctx context.Context, app app.ArduinoApp) ([]LibraryRele
107108 }
108109
109110 // Keep only index libraries
110- libs := f .Filter (resp .Libraries , func (l * rpc.SketchProfileLibraryReference ) bool {
111+ libs := f .Filter (resp .Libraries , func (l * rpc.ProfileLibraryReference ) bool {
111112 return l .GetIndexLibrary () != nil
112113 })
113- res := f .Map (libs , func (l * rpc.SketchProfileLibraryReference ) LibraryReleaseID {
114- return LibraryReleaseID {
115- Name : l .GetIndexLibrary ().GetName (),
116- Version : l .GetIndexLibrary ().GetVersion (),
117- }
118- })
119- return res , nil
114+ return f .Map (libs , rpcProfileLibReferenceToLibReleaseID ), nil
120115}
121116
122- func rpcProfileLibReferenceToLibReleaseID (ref * rpc.SketchProfileLibraryReference ) LibraryReleaseID {
117+ func rpcProfileLibReferenceToLibReleaseID (ref * rpc.ProfileLibraryReference ) LibraryReleaseID {
123118 l := ref .GetIndexLibrary ()
124- return NewLibraryReleaseID (l .GetName (), l .GetVersion ())
119+ return LibraryReleaseID {
120+ Name : l .GetName (),
121+ Version : l .GetVersion (),
122+ IsDependency : l .GetIsDependency (),
123+ }
125124}
0 commit comments