doc: print available modules

pull/4905/head
Alexander Medvednikov 2020-05-15 23:09:38 +02:00
parent 2dbb4c2ca7
commit 7caebc5781
2 changed files with 18 additions and 5 deletions

View File

@ -92,12 +92,15 @@ fn main_v() {
return
}
'doc' {
mut mod := ''
if args.len == 1 {
println('v doc [module]')
exit(1)
}
else if args.len > 1 {
mod = args[1]
}
table := table.new_table()
println(doc.doc(args[1], table, prefs))
println(doc.doc(mod, table, prefs))
return
}
else {}

View File

@ -26,9 +26,19 @@ pub fn doc(mod string, table &table.Table, prefs &pref.Preferences) string {
vlib_path := os.dir(pref.vexe_path()) + '/vlib'
mod_path := mod.replace('.', os.path_separator)
path := os.join_path(vlib_path, mod_path)
if !os.exists(path) {
println('module "$mod" not found')
println(path)
if mod == '' || !os.exists(path) {
if mod != '' {
println('module "$mod" not found')
}
println('\navailable modules:')
mut files := os.ls(vlib_path) or {
return ''
}
files.sort()
for file in files {
println(file)
}
// println(path)
return ''
}
// vfiles := os.walk_ext(path, '.v')