@@ -40,65 +40,92 @@ func initInstallCommand() *cobra.Command {
40
40
Run : runInstallCommand ,
41
41
}
42
42
installCommand .Flags ().BoolVar (& installFlags .noDeps , "no-deps" , false , "Do not install dependencies." )
43
+ installCommand .Flags ().StringVarP (& installFlags .gitURL , "git-url" , "g" , "" , "Enter git url for libraries hosted on repositories" )
44
+ installCommand .Flags ().StringVarP (& installFlags .zipPath , "zip-path" , "z" , "" , "Enter a path to zip file" )
43
45
return installCommand
44
46
}
45
47
46
48
var installFlags struct {
47
- noDeps bool
49
+ noDeps bool
50
+ gitURL string
51
+ zipPath string
48
52
}
49
53
50
54
func runInstallCommand (cmd * cobra.Command , args []string ) {
51
55
instance := instance .CreateInstanceIgnorePlatformIndexErrors ()
52
- libRefs , err := ParseLibraryReferenceArgsAndAdjustCase (instance , args )
53
- if err != nil {
54
- feedback .Errorf ("Arguments error: %v" , err )
55
- os .Exit (errorcodes .ErrBadArgument )
56
- }
57
-
58
- toInstall := map [string ]* rpc.LibraryDependencyStatus {}
59
- if installFlags .noDeps {
60
- for _ , libRef := range libRefs {
61
- toInstall [libRef .Name ] = & rpc.LibraryDependencyStatus {
62
- Name : libRef .Name ,
63
- VersionRequired : libRef .Version ,
64
- }
56
+ if installFlags .zipPath != "" {
57
+ ZiplibraryInstallReq := & rpc.ZipLibraryInstallReq {
58
+ Instance : instance ,
59
+ Path : installFlags .zipPath ,
60
+ }
61
+ _ , err := lib .ZipLibraryInstall (context .Background (), ZiplibraryInstallReq )
62
+ if err != nil {
63
+ feedback .Errorf ("Error installing Zip Library %v" , err )
64
+ os .Exit (errorcodes .ErrGeneric )
65
+ }
66
+ } else if installFlags .gitURL != "" {
67
+ GitlibraryInstallReq := & rpc.GitLibraryInstallReq {
68
+ Instance : instance ,
69
+ Name : args [0 ],
70
+ Url : installFlags .gitURL ,
71
+ }
72
+ _ , err := lib .GitLibraryInstall (context .Background (), GitlibraryInstallReq )
73
+ if err != nil {
74
+ feedback .Errorf ("Error installing Git Library %v" , err )
75
+ os .Exit (errorcodes .ErrGeneric )
65
76
}
66
77
} else {
67
- for _ , libRef := range libRefs {
68
- depsResp , err := lib .LibraryResolveDependencies (context .Background (), & rpc.LibraryResolveDependenciesReq {
69
- Instance : instance ,
70
- Name : libRef .Name ,
71
- Version : libRef .Version ,
72
- })
73
- if err != nil {
74
- feedback .Errorf ("Error resolving dependencies for %s: %s" , libRef , err )
75
- os .Exit (errorcodes .ErrGeneric )
78
+ libRefs , err := ParseLibraryReferenceArgsAndAdjustCase (instance , args )
79
+ if err != nil {
80
+ feedback .Errorf ("Arguments error: %v" , err )
81
+ os .Exit (errorcodes .ErrBadArgument )
82
+ }
83
+
84
+ toInstall := map [string ]* rpc.LibraryDependencyStatus {}
85
+ if installFlags .noDeps {
86
+ for _ , libRef := range libRefs {
87
+ toInstall [libRef .Name ] = & rpc.LibraryDependencyStatus {
88
+ Name : libRef .Name ,
89
+ VersionRequired : libRef .Version ,
90
+ }
76
91
}
77
- for _ , dep := range depsResp .GetDependencies () {
78
- feedback .Printf ("%s depends on %s@%s" , libRef , dep .GetName (), dep .GetVersionRequired ())
79
- if existingDep , has := toInstall [dep .GetName ()]; has {
80
- if existingDep .GetVersionRequired () != dep .GetVersionRequired () {
81
- // TODO: make a better error
82
- feedback .Errorf ("The library %s is required in two different versions: %s and %s" ,
83
- dep .GetName (), dep .GetVersionRequired (), existingDep .GetVersionRequired ())
84
- os .Exit (errorcodes .ErrGeneric )
92
+ } else {
93
+ for _ , libRef := range libRefs {
94
+ depsResp , err := lib .LibraryResolveDependencies (context .Background (), & rpc.LibraryResolveDependenciesReq {
95
+ Instance : instance ,
96
+ Name : libRef .Name ,
97
+ Version : libRef .Version ,
98
+ })
99
+ if err != nil {
100
+ feedback .Errorf ("Error resolving dependencies for %s: %s" , libRef , err )
101
+ os .Exit (errorcodes .ErrGeneric )
102
+ }
103
+ for _ , dep := range depsResp .GetDependencies () {
104
+ feedback .Printf ("%s depends on %s@%s" , libRef , dep .GetName (), dep .GetVersionRequired ())
105
+ if existingDep , has := toInstall [dep .GetName ()]; has {
106
+ if existingDep .GetVersionRequired () != dep .GetVersionRequired () {
107
+ // TODO: make a better error
108
+ feedback .Errorf ("The library %s is required in two different versions: %s and %s" ,
109
+ dep .GetName (), dep .GetVersionRequired (), existingDep .GetVersionRequired ())
110
+ os .Exit (errorcodes .ErrGeneric )
111
+ }
85
112
}
113
+ toInstall [dep .GetName ()] = dep
86
114
}
87
- toInstall [dep .GetName ()] = dep
88
115
}
89
116
}
90
- }
91
117
92
- for _ , library := range toInstall {
93
- libraryInstallReq := & rpc.LibraryInstallReq {
94
- Instance : instance ,
95
- Name : library .Name ,
96
- Version : library .VersionRequired ,
97
- }
98
- err := lib .LibraryInstall (context .Background (), libraryInstallReq , output .ProgressBar (), output .TaskProgress ())
99
- if err != nil {
100
- feedback .Errorf ("Error installing %s: %v" , library , err )
101
- os .Exit (errorcodes .ErrGeneric )
118
+ for _ , library := range toInstall {
119
+ libraryInstallReq := & rpc.LibraryInstallReq {
120
+ Instance : instance ,
121
+ Name : library .Name ,
122
+ Version : library .VersionRequired ,
123
+ }
124
+ err := lib .LibraryInstall (context .Background (), libraryInstallReq , output .ProgressBar (), output .TaskProgress ())
125
+ if err != nil {
126
+ feedback .Errorf ("Error installing %s: %v" , library , err )
127
+ os .Exit (errorcodes .ErrGeneric )
128
+ }
102
129
}
103
130
}
104
131
}
0 commit comments