vpm: support `v install -once module_name`(#13977)
parent
e3da3101f6
commit
804f2f56d4
|
@ -87,6 +87,12 @@ fn main() {
|
||||||
module_names = manifest.dependencies
|
module_names = manifest.dependencies
|
||||||
}
|
}
|
||||||
mut source := Source.vpm
|
mut source := Source.vpm
|
||||||
|
if '--once' in options {
|
||||||
|
module_names = vpm_once_filter(module_names)
|
||||||
|
if module_names.len == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
if '--git' in options {
|
if '--git' in options {
|
||||||
source = Source.git
|
source = Source.git
|
||||||
}
|
}
|
||||||
|
@ -327,6 +333,17 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vpm_once_filter(module_names []string) []string {
|
||||||
|
installed_modules := get_installed_modules()
|
||||||
|
mut toinstall := []string{}
|
||||||
|
for mn in module_names {
|
||||||
|
if mn !in installed_modules {
|
||||||
|
toinstall << mn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return toinstall
|
||||||
|
}
|
||||||
|
|
||||||
fn vpm_install(module_names []string, source Source) {
|
fn vpm_install(module_names []string, source Source) {
|
||||||
if settings.is_help {
|
if settings.is_help {
|
||||||
vhelp.show_topic('install')
|
vhelp.show_topic('install')
|
||||||
|
@ -336,15 +353,16 @@ fn vpm_install(module_names []string, source Source) {
|
||||||
println('´v install´ requires *at least one* module name.')
|
println('´v install´ requires *at least one* module name.')
|
||||||
exit(2)
|
exit(2)
|
||||||
}
|
}
|
||||||
|
match source {
|
||||||
if source == .vpm {
|
.vpm {
|
||||||
vpm_install_from_vpm(module_names)
|
vpm_install_from_vpm(module_names)
|
||||||
}
|
}
|
||||||
if source == .git {
|
.git {
|
||||||
vpm_install_from_vcs(module_names, 'git')
|
vpm_install_from_vcs(module_names, 'git')
|
||||||
}
|
}
|
||||||
if source == .hg {
|
.hg {
|
||||||
vpm_install_from_vcs(module_names, 'hg')
|
vpm_install_from_vcs(module_names, 'hg')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ Options:
|
||||||
--vpm - [Default] Install from vpm
|
--vpm - [Default] Install from vpm
|
||||||
--git - Install from git repository url
|
--git - Install from git repository url
|
||||||
--hg - Install from mercurial repository url
|
--hg - Install from mercurial repository url
|
||||||
|
--once - Only install the module if it was not previously installed
|
||||||
-help - Show usage info.
|
-help - Show usage info.
|
||||||
-v - Print more details about the performed operation.
|
-v - Print more details about the performed operation.
|
||||||
-server-url - When doing network operations, use this vpm server. Can be given multiple times.
|
-server-url - When doing network operations, use this vpm server. Can be given multiple times.
|
||||||
|
|
|
@ -4601,13 +4601,19 @@ v install ui
|
||||||
|
|
||||||
Modules can be installed directly from git or mercurial repositories.
|
Modules can be installed directly from git or mercurial repositories.
|
||||||
```powershell
|
```powershell
|
||||||
v install [--git|--hg] [url]
|
v install [--once] [--git|--hg] [url]
|
||||||
```
|
```
|
||||||
**Example:**
|
**Example:**
|
||||||
```powershell
|
```powershell
|
||||||
v install --git https://github.com/vlang/markdown
|
v install --git https://github.com/vlang/markdown
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Sometimes you may want to install the dependencies **ONLY** if those are not installed:
|
||||||
|
|
||||||
|
```
|
||||||
|
v install --once [module]
|
||||||
|
```
|
||||||
|
|
||||||
Removing a module with v:
|
Removing a module with v:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
|
Loading…
Reference in New Issue