@@ -34,14 +34,12 @@ import (
3434 semver "go.bug.st/relaxed-semver"
3535)
3636
37- var (
38- noDeps bool
39- noOverwrite bool
40- gitURL bool
41- zipPath bool
42- )
43-
4437func initInstallCommand () * cobra.Command {
38+ var noDeps bool
39+ var noOverwrite bool
40+ var gitURL bool
41+ var zipPath bool
42+ var useBuiltinLibrariesDir bool
4543 installCommand := & cobra.Command {
4644 Use : fmt .Sprintf ("install %s[@%s]..." , tr ("LIBRARY" ), tr ("VERSION_NUMBER" )),
4745 Short : tr ("Installs one or more specified libraries into the system." ),
@@ -53,7 +51,9 @@ func initInstallCommand() *cobra.Command {
5351 " " + os .Args [0 ] + " lib install --git-url https://github.com/arduino-libraries/WiFi101.git#0.16.0 # " + tr ("for the specific version." ) + "\n " +
5452 " " + os .Args [0 ] + " lib install --zip-path /path/to/WiFi101.zip /path/to/ArduinoBLE.zip\n " ,
5553 Args : cobra .MinimumNArgs (1 ),
56- Run : runInstallCommand ,
54+ Run : func (cmd * cobra.Command , args []string ) {
55+ runInstallCommand (args , noDeps , noOverwrite , gitURL , zipPath , useBuiltinLibrariesDir )
56+ },
5757 ValidArgsFunction : func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
5858 return arguments .GetInstallableLibs (), cobra .ShellCompDirectiveDefault
5959 },
@@ -62,10 +62,11 @@ func initInstallCommand() *cobra.Command {
6262 installCommand .Flags ().BoolVar (& noOverwrite , "no-overwrite" , false , tr ("Do not overwrite already installed libraries." ))
6363 installCommand .Flags ().BoolVar (& gitURL , "git-url" , false , tr ("Enter git url for libraries hosted on repositories" ))
6464 installCommand .Flags ().BoolVar (& zipPath , "zip-path" , false , tr ("Enter a path to zip file" ))
65+ installCommand .Flags ().BoolVar (& useBuiltinLibrariesDir , "install-in-builtin-dir" , false , tr ("Install libraries in the IDE-Builtin directory" ))
6566 return installCommand
6667}
6768
68- func runInstallCommand (cmd * cobra. Command , args []string ) {
69+ func runInstallCommand (args []string , noDeps bool , noOverwrite bool , gitURL bool , zipPath bool , useBuiltinLibrariesDir bool ) {
6970 instance := instance .CreateAndInit ()
7071 logrus .Info ("Executing `arduino-cli lib install`" )
7172
@@ -80,6 +81,10 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
8081 feedback .Fatal (tr ("--git-url and --zip-path are disabled by default, for more information see: %v" , documentationURL ), feedback .ErrGeneric )
8182 }
8283 feedback .Print (tr ("--git-url and --zip-path flags allow installing untrusted files, use it at your own risk." ))
84+
85+ if useBuiltinLibrariesDir {
86+ feedback .Fatal (tr ("--git-url or --zip-path can't be used with --install-in-builtin-dir" ), feedback .ErrGeneric )
87+ }
8388 }
8489
8590 if zipPath {
@@ -123,12 +128,17 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
123128 }
124129
125130 for _ , libRef := range libRefs {
131+ installLocation := rpc .LibraryInstallLocation_LIBRARY_INSTALL_LOCATION_USER
132+ if useBuiltinLibrariesDir {
133+ installLocation = rpc .LibraryInstallLocation_LIBRARY_INSTALL_LOCATION_BUILTIN
134+ }
126135 libraryInstallRequest := & rpc.LibraryInstallRequest {
127- Instance : instance ,
128- Name : libRef .Name ,
129- Version : libRef .Version ,
130- NoDeps : noDeps ,
131- NoOverwrite : noOverwrite ,
136+ Instance : instance ,
137+ Name : libRef .Name ,
138+ Version : libRef .Version ,
139+ NoDeps : noDeps ,
140+ NoOverwrite : noOverwrite ,
141+ InstallLocation : installLocation ,
132142 }
133143 err := lib .LibraryInstall (context .Background (), libraryInstallRequest , feedback .ProgressBar (), feedback .TaskProgress ())
134144 if err != nil {
0 commit comments