@@ -39,6 +39,7 @@ func initInstallCommand() *cobra.Command {
39
39
var noOverwrite bool
40
40
var gitURL bool
41
41
var zipPath bool
42
+ var useBuiltinLibrariesDir bool
42
43
installCommand := & cobra.Command {
43
44
Use : fmt .Sprintf ("install %s[@%s]..." , tr ("LIBRARY" ), tr ("VERSION_NUMBER" )),
44
45
Short : tr ("Installs one or more specified libraries into the system." ),
@@ -51,7 +52,7 @@ func initInstallCommand() *cobra.Command {
51
52
" " + os .Args [0 ] + " lib install --zip-path /path/to/WiFi101.zip /path/to/ArduinoBLE.zip\n " ,
52
53
Args : cobra .MinimumNArgs (1 ),
53
54
Run : func (cmd * cobra.Command , args []string ) {
54
- runInstallCommand (args , noDeps , noOverwrite , gitURL , zipPath )
55
+ runInstallCommand (args , noDeps , noOverwrite , gitURL , zipPath , useBuiltinLibrariesDir )
55
56
},
56
57
ValidArgsFunction : func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
57
58
return arguments .GetInstallableLibs (), cobra .ShellCompDirectiveDefault
@@ -61,10 +62,11 @@ func initInstallCommand() *cobra.Command {
61
62
installCommand .Flags ().BoolVar (& noOverwrite , "no-overwrite" , false , tr ("Do not overwrite already installed libraries." ))
62
63
installCommand .Flags ().BoolVar (& gitURL , "git-url" , false , tr ("Enter git url for libraries hosted on repositories" ))
63
64
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" ))
64
66
return installCommand
65
67
}
66
68
67
- func runInstallCommand (args []string , noDeps bool , noOverwrite bool , gitURL bool , zipPath bool ) {
69
+ func runInstallCommand (args []string , noDeps bool , noOverwrite bool , gitURL bool , zipPath bool , useBuiltinLibrariesDir bool ) {
68
70
instance := instance .CreateAndInit ()
69
71
logrus .Info ("Executing `arduino-cli lib install`" )
70
72
@@ -79,6 +81,10 @@ func runInstallCommand(args []string, noDeps bool, noOverwrite bool, gitURL bool
79
81
feedback .Fatal (tr ("--git-url and --zip-path are disabled by default, for more information see: %v" , documentationURL ), feedback .ErrGeneric )
80
82
}
81
83
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
+ }
82
88
}
83
89
84
90
if zipPath {
@@ -122,12 +128,17 @@ func runInstallCommand(args []string, noDeps bool, noOverwrite bool, gitURL bool
122
128
}
123
129
124
130
for _ , libRef := range libRefs {
131
+ installLocation := rpc .LibraryInstallLocation_LIBRARY_INSTALL_LOCATION_USER
132
+ if useBuiltinLibrariesDir {
133
+ installLocation = rpc .LibraryInstallLocation_LIBRARY_INSTALL_LOCATION_BUILTIN
134
+ }
125
135
libraryInstallRequest := & rpc.LibraryInstallRequest {
126
- Instance : instance ,
127
- Name : libRef .Name ,
128
- Version : libRef .Version ,
129
- NoDeps : noDeps ,
130
- NoOverwrite : noOverwrite ,
136
+ Instance : instance ,
137
+ Name : libRef .Name ,
138
+ Version : libRef .Version ,
139
+ NoDeps : noDeps ,
140
+ NoOverwrite : noOverwrite ,
141
+ InstallLocation : installLocation ,
131
142
}
132
143
err := lib .LibraryInstall (context .Background (), libraryInstallRequest , feedback .ProgressBar (), feedback .TaskProgress ())
133
144
if err != nil {
0 commit comments