vpm: addd a show command (#10186)
parent
13d1d28db1
commit
da88235bdc
|
@ -21,6 +21,10 @@ fn cerror(e string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_name(name string) string {
|
fn check_name(name string) string {
|
||||||
|
if name.trim_space().len == 0 {
|
||||||
|
cerror('project name cannot be empty')
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
if name.is_title() {
|
if name.is_title() {
|
||||||
mut cname := name.to_lower()
|
mut cname := name.to_lower()
|
||||||
if cname.contains(' ') {
|
if cname.contains(' ') {
|
||||||
|
@ -157,6 +161,7 @@ fn init_project() {
|
||||||
c.write_vmod(false)
|
c.write_vmod(false)
|
||||||
c.write_main(false)
|
c.write_main(false)
|
||||||
c.create_git_repo('')
|
c.create_git_repo('')
|
||||||
|
|
||||||
println("Change your module's description in `v.mod`")
|
println("Change your module's description in `v.mod`")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import v.vmod
|
||||||
const (
|
const (
|
||||||
default_vpm_server_urls = ['https://vpm.vlang.io']
|
default_vpm_server_urls = ['https://vpm.vlang.io']
|
||||||
valid_vpm_commands = ['help', 'search', 'install', 'update', 'upgrade', 'outdated',
|
valid_vpm_commands = ['help', 'search', 'install', 'update', 'upgrade', 'outdated',
|
||||||
'list', 'remove']
|
'list', 'remove', 'show']
|
||||||
excluded_dirs = ['cache', 'vlib']
|
excluded_dirs = ['cache', 'vlib']
|
||||||
supported_vcs_systems = ['git', 'hg']
|
supported_vcs_systems = ['git', 'hg']
|
||||||
supported_vcs_folders = ['.git', '.hg']
|
supported_vcs_folders = ['.git', '.hg']
|
||||||
|
@ -91,6 +91,9 @@ fn main() {
|
||||||
'remove' {
|
'remove' {
|
||||||
vpm_remove(module_names)
|
vpm_remove(module_names)
|
||||||
}
|
}
|
||||||
|
'show' {
|
||||||
|
vpm_show(module_names)
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
println('Error: you tried to run "v $vpm_command"')
|
println('Error: you tried to run "v $vpm_command"')
|
||||||
println('... but the v package management tool vpm only knows about these commands:')
|
println('... but the v package management tool vpm only knows about these commands:')
|
||||||
|
@ -567,3 +570,43 @@ fn get_module_meta_info(name string) ?Mod {
|
||||||
}
|
}
|
||||||
return error(errors.join_lines())
|
return error(errors.join_lines())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vpm_show(module_names []string) {
|
||||||
|
installed_modules := get_installed_modules()
|
||||||
|
for module_name in module_names {
|
||||||
|
if module_name !in installed_modules {
|
||||||
|
module_meta_info := get_module_meta_info(module_name) or { continue }
|
||||||
|
print('
|
||||||
|
Name: $module_meta_info.name
|
||||||
|
Homepage: $module_meta_info.url
|
||||||
|
Downloads: $module_meta_info.nr_downloads
|
||||||
|
Installed: False
|
||||||
|
--------
|
||||||
|
')
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
path := os.join_path(os.vmodules_dir(), module_name)
|
||||||
|
mod := vmod.from_file(os.join_path(path, 'v.mod')) or { continue }
|
||||||
|
// console_output := [
|
||||||
|
// 'Name: $mod.name',
|
||||||
|
// 'Version: $mod.version',
|
||||||
|
// 'Description: $mod.description',
|
||||||
|
// 'Homepage: $mod.repo_url',
|
||||||
|
// 'Author: $mod.author',
|
||||||
|
// 'License: $mod.license',
|
||||||
|
// 'Location: $path',
|
||||||
|
// 'Requires: ${mod.dependencies.join(', ')}',
|
||||||
|
// ].join('\n')
|
||||||
|
// println('${console_output}\n--------\n')
|
||||||
|
print('Name: $mod.name
|
||||||
|
Version: $mod.version
|
||||||
|
Description: $mod.description
|
||||||
|
Homepage: $mod.repo_url
|
||||||
|
Author: $mod.author
|
||||||
|
License: $mod.license
|
||||||
|
Location: $path
|
||||||
|
Requires: ${mod.dependencies.join(', ')}
|
||||||
|
--------
|
||||||
|
')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue