mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vpm: replace println with eprintln, for printing error output (#15992)
This commit is contained in:
@ -126,10 +126,10 @@ fn main() {
|
|||||||
vpm_show(module_names)
|
vpm_show(module_names)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println('Error: you tried to run "v $vpm_command"')
|
eprintln('Error: you tried to run "v $vpm_command"')
|
||||||
println('... but the v package management tool vpm only knows about these commands:')
|
eprintln('... but the v package management tool vpm only knows about these commands:')
|
||||||
for validcmd in valid_vpm_commands {
|
for validcmd in valid_vpm_commands {
|
||||||
println(' v $validcmd')
|
eprintln(' v $validcmd')
|
||||||
}
|
}
|
||||||
exit(3)
|
exit(3)
|
||||||
}
|
}
|
||||||
@ -143,7 +143,7 @@ fn vpm_search(keywords []string) {
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if search_keys.len == 0 {
|
if search_keys.len == 0 {
|
||||||
println('´v search´ requires *at least one* keyword.')
|
eprintln('´v search´ requires *at least one* keyword.')
|
||||||
exit(2)
|
exit(2)
|
||||||
}
|
}
|
||||||
modules := get_all_modules()
|
modules := get_all_modules()
|
||||||
@ -185,7 +185,7 @@ fn vpm_search(keywords []string) {
|
|||||||
println(m)
|
println(m)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println('\nUse "v install author_name.module_name" to install the module.')
|
eprintln('\nUse "v install author_name.module_name" to install the module.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +195,8 @@ fn vpm_install_from_vpm(module_names []string) {
|
|||||||
name := n.trim_space().replace('_', '-')
|
name := n.trim_space().replace('_', '-')
|
||||||
mod := get_module_meta_info(name) or {
|
mod := get_module_meta_info(name) or {
|
||||||
errors++
|
errors++
|
||||||
println('Errors while retrieving meta data for module $name:')
|
eprintln('Errors while retrieving meta data for module $name:')
|
||||||
println(err)
|
eprintln(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
mut vcs := mod.vcs
|
mut vcs := mod.vcs
|
||||||
@ -205,12 +205,12 @@ fn vpm_install_from_vpm(module_names []string) {
|
|||||||
}
|
}
|
||||||
if vcs !in supported_vcs_systems {
|
if vcs !in supported_vcs_systems {
|
||||||
errors++
|
errors++
|
||||||
println('Skipping module "$name", since it uses an unsupported VCS {$vcs} .')
|
eprintln('Skipping module "$name", since it uses an unsupported VCS {$vcs} .')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !ensure_vcs_is_installed(vcs) {
|
if !ensure_vcs_is_installed(vcs) {
|
||||||
errors++
|
errors++
|
||||||
println('VPM needs `$vcs` to be installed.')
|
eprintln('VPM needs `$vcs` to be installed.')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -226,7 +226,7 @@ fn vpm_install_from_vpm(module_names []string) {
|
|||||||
cmdres := os.execute(cmd)
|
cmdres := os.execute(cmd)
|
||||||
if cmdres.exit_code != 0 {
|
if cmdres.exit_code != 0 {
|
||||||
errors++
|
errors++
|
||||||
println('Failed installing module "$name" to "$minfo.final_module_path" .')
|
eprintln('Failed installing module "$name" to "$minfo.final_module_path" .')
|
||||||
print_failed_cmd(cmd, cmdres)
|
print_failed_cmd(cmd, cmdres)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -260,8 +260,8 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
|||||||
|
|
||||||
first_cut_pos := url.last_index('/') or {
|
first_cut_pos := url.last_index('/') or {
|
||||||
errors++
|
errors++
|
||||||
println('Errors while retrieving name for module "$url" :')
|
eprintln('Errors while retrieving name for module "$url" :')
|
||||||
println(err)
|
eprintln(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,8 +269,8 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
|||||||
|
|
||||||
second_cut_pos := url.substr(0, first_cut_pos).last_index('/') or {
|
second_cut_pos := url.substr(0, first_cut_pos).last_index('/') or {
|
||||||
errors++
|
errors++
|
||||||
println('Errors while retrieving name for module "$url" :')
|
eprintln('Errors while retrieving name for module "$url" :')
|
||||||
println(err)
|
eprintln(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
|||||||
}
|
}
|
||||||
if !ensure_vcs_is_installed(vcs_key) {
|
if !ensure_vcs_is_installed(vcs_key) {
|
||||||
errors++
|
errors++
|
||||||
println('VPM needs `$vcs_key` to be installed.')
|
eprintln('VPM needs `$vcs_key` to be installed.')
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
println('Installing module "$name" from "$url" to "$final_module_path" ...')
|
println('Installing module "$name" from "$url" to "$final_module_path" ...')
|
||||||
@ -294,7 +294,7 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
|||||||
cmdres := os.execute(cmd)
|
cmdres := os.execute(cmd)
|
||||||
if cmdres.exit_code != 0 {
|
if cmdres.exit_code != 0 {
|
||||||
errors++
|
errors++
|
||||||
println('Failed installing module "$name" to "$final_module_path" .')
|
eprintln('Failed installing module "$name" to "$final_module_path" .')
|
||||||
print_failed_cmd(cmd, cmdres)
|
print_failed_cmd(cmd, cmdres)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -305,8 +305,8 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
|||||||
minfo := mod_name_info(vmod.name)
|
minfo := mod_name_info(vmod.name)
|
||||||
println('Relocating module from "$name" to "$vmod.name" ( "$minfo.final_module_path" ) ...')
|
println('Relocating module from "$name" to "$vmod.name" ( "$minfo.final_module_path" ) ...')
|
||||||
if os.exists(minfo.final_module_path) {
|
if os.exists(minfo.final_module_path) {
|
||||||
println('Warning module "$minfo.final_module_path" already exsits!')
|
eprintln('Warning module "$minfo.final_module_path" already exsits!')
|
||||||
println('Removing module "$minfo.final_module_path" ...')
|
eprintln('Removing module "$minfo.final_module_path" ...')
|
||||||
os.rmdir_all(minfo.final_module_path) or {
|
os.rmdir_all(minfo.final_module_path) or {
|
||||||
errors++
|
errors++
|
||||||
println('Errors while removing "$minfo.final_module_path" :')
|
println('Errors while removing "$minfo.final_module_path" :')
|
||||||
@ -316,12 +316,12 @@ fn vpm_install_from_vcs(module_names []string, vcs_key string) {
|
|||||||
}
|
}
|
||||||
os.mv(final_module_path, minfo.final_module_path) or {
|
os.mv(final_module_path, minfo.final_module_path) or {
|
||||||
errors++
|
errors++
|
||||||
println('Errors while relocating module "$name" :')
|
eprintln('Errors while relocating module "$name" :')
|
||||||
println(err)
|
eprintln(err)
|
||||||
os.rmdir_all(final_module_path) or {
|
os.rmdir_all(final_module_path) or {
|
||||||
errors++
|
errors++
|
||||||
println('Errors while removing "$final_module_path" :')
|
eprintln('Errors while removing "$final_module_path" :')
|
||||||
println(err)
|
eprintln(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@ -354,7 +354,7 @@ fn vpm_install(module_names []string, source Source) {
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if module_names.len == 0 {
|
if module_names.len == 0 {
|
||||||
println('´v install´ requires *at least one* module name.')
|
eprintln('´v install´ requires *at least one* module name.')
|
||||||
exit(2)
|
exit(2)
|
||||||
}
|
}
|
||||||
match source {
|
match source {
|
||||||
@ -452,9 +452,9 @@ fn vpm_upgrade() {
|
|||||||
fn vpm_outdated() {
|
fn vpm_outdated() {
|
||||||
outdated := get_outdated() or { exit(1) }
|
outdated := get_outdated() or { exit(1) }
|
||||||
if outdated.len > 0 {
|
if outdated.len > 0 {
|
||||||
println('Outdated modules:')
|
eprintln('Outdated modules:')
|
||||||
for m in outdated {
|
for m in outdated {
|
||||||
println(' $m')
|
eprintln(' $m')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println('Modules are up to date.')
|
println('Modules are up to date.')
|
||||||
@ -478,12 +478,12 @@ fn vpm_remove(module_names []string) {
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if module_names.len == 0 {
|
if module_names.len == 0 {
|
||||||
println('´v remove´ requires *at least one* module name.')
|
eprintln('´v remove´ requires *at least one* module name.')
|
||||||
exit(2)
|
exit(2)
|
||||||
}
|
}
|
||||||
for name in module_names {
|
for name in module_names {
|
||||||
final_module_path := valid_final_path_of_existing_module(name) or { continue }
|
final_module_path := valid_final_path_of_existing_module(name) or { continue }
|
||||||
println('Removing module "$name" ...')
|
eprintln('Removing module "$name" ...')
|
||||||
verbose_println('removing folder $final_module_path')
|
verbose_println('removing folder $final_module_path')
|
||||||
os.rmdir_all(final_module_path) or {
|
os.rmdir_all(final_module_path) or {
|
||||||
verbose_println('error while removing "$final_module_path": $err.msg()')
|
verbose_println('error while removing "$final_module_path": $err.msg()')
|
||||||
@ -507,15 +507,15 @@ fn valid_final_path_of_existing_module(modulename string) ?string {
|
|||||||
name := if mod := get_mod_by_url(modulename) { mod.name } else { modulename }
|
name := if mod := get_mod_by_url(modulename) { mod.name } else { modulename }
|
||||||
minfo := mod_name_info(name)
|
minfo := mod_name_info(name)
|
||||||
if !os.exists(minfo.final_module_path) {
|
if !os.exists(minfo.final_module_path) {
|
||||||
println('No module with name "$minfo.mname_normalised" exists at $minfo.final_module_path')
|
eprintln('No module with name "$minfo.mname_normalised" exists at $minfo.final_module_path')
|
||||||
return none
|
return none
|
||||||
}
|
}
|
||||||
if !os.is_dir(minfo.final_module_path) {
|
if !os.is_dir(minfo.final_module_path) {
|
||||||
println('Skipping "$minfo.final_module_path", since it is not a folder.')
|
eprintln('Skipping "$minfo.final_module_path", since it is not a folder.')
|
||||||
return none
|
return none
|
||||||
}
|
}
|
||||||
vcs_used_in_dir(minfo.final_module_path) or {
|
vcs_used_in_dir(minfo.final_module_path) or {
|
||||||
println('Skipping "$minfo.final_module_path", since it does not use a supported vcs.')
|
eprintln('Skipping "$minfo.final_module_path", since it does not use a supported vcs.')
|
||||||
return none
|
return none
|
||||||
}
|
}
|
||||||
return minfo.final_module_path
|
return minfo.final_module_path
|
||||||
@ -598,7 +598,7 @@ fn get_all_modules() []string {
|
|||||||
url := get_working_server_url()
|
url := get_working_server_url()
|
||||||
r := http.get(url) or { panic(err) }
|
r := http.get(url) or { panic(err) }
|
||||||
if r.status_code != 200 {
|
if r.status_code != 200 {
|
||||||
println('Failed to search vpm.vlang.io. Status code: $r.status_code')
|
eprintln('Failed to search vpm.vlang.io. Status code: $r.status_code')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
s := r.body
|
s := r.body
|
||||||
|
Reference in New Issue
Block a user