@@ -34,14 +34,12 @@ import (
34
34
semver "go.bug.st/relaxed-semver"
35
35
)
36
36
37
- var (
38
- noDeps bool
39
- noOverwrite bool
40
- gitURL bool
41
- zipPath bool
42
- )
43
-
44
37
func initInstallCommand () * cobra.Command {
38
+ var noDeps bool
39
+ var noOverwrite bool
40
+ var gitURL bool
41
+ var zipPath bool
42
+ var useBuiltinLibrariesDir bool
45
43
installCommand := & cobra.Command {
46
44
Use : fmt .Sprintf ("install %s[@%s]..." , tr ("LIBRARY" ), tr ("VERSION_NUMBER" )),
47
45
Short : tr ("Installs one or more specified libraries into the system." ),
@@ -53,7 +51,9 @@ func initInstallCommand() *cobra.Command {
53
51
" " + os .Args [0 ] + " lib install --git-url https://github.com/arduino-libraries/WiFi101.git#0.16.0 # " + tr ("for the specific version." ) + "\n " +
54
52
" " + os .Args [0 ] + " lib install --zip-path /path/to/WiFi101.zip /path/to/ArduinoBLE.zip\n " ,
55
53
Args : cobra .MinimumNArgs (1 ),
56
- Run : runInstallCommand ,
54
+ Run : func (cmd * cobra.Command , args []string ) {
55
+ runInstallCommand (args , noDeps , noOverwrite , gitURL , zipPath , useBuiltinLibrariesDir )
56
+ },
57
57
ValidArgsFunction : func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
58
58
return arguments .GetInstallableLibs (), cobra .ShellCompDirectiveDefault
59
59
},
@@ -62,10 +62,11 @@ func initInstallCommand() *cobra.Command {
62
62
installCommand .Flags ().BoolVar (& noOverwrite , "no-overwrite" , false , tr ("Do not overwrite already installed libraries." ))
63
63
installCommand .Flags ().BoolVar (& gitURL , "git-url" , false , tr ("Enter git url for libraries hosted on repositories" ))
64
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" ))
65
66
return installCommand
66
67
}
67
68
68
- func runInstallCommand (cmd * cobra. Command , args []string ) {
69
+ func runInstallCommand (args []string , noDeps bool , noOverwrite bool , gitURL bool , zipPath bool , useBuiltinLibrariesDir bool ) {
69
70
instance := instance .CreateAndInit ()
70
71
logrus .Info ("Executing `arduino-cli lib install`" )
71
72
@@ -80,6 +81,10 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
80
81
feedback .Fatal (tr ("--git-url and --zip-path are disabled by default, for more information see: %v" , documentationURL ), feedback .ErrGeneric )
81
82
}
82
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
+ }
83
88
}
84
89
85
90
if zipPath {
@@ -123,12 +128,17 @@ func runInstallCommand(cmd *cobra.Command, args []string) {
123
128
}
124
129
125
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
+ }
126
135
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 ,
132
142
}
133
143
err := lib .LibraryInstall (context .Background (), libraryInstallRequest , feedback .ProgressBar (), feedback .TaskProgress ())
134
144
if err != nil {
0 commit comments