doc: print available modules
parent
2dbb4c2ca7
commit
7caebc5781
|
@ -92,12 +92,15 @@ fn main_v() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
'doc' {
|
'doc' {
|
||||||
|
mut mod := ''
|
||||||
if args.len == 1 {
|
if args.len == 1 {
|
||||||
println('v doc [module]')
|
println('v doc [module]')
|
||||||
exit(1)
|
}
|
||||||
|
else if args.len > 1 {
|
||||||
|
mod = args[1]
|
||||||
}
|
}
|
||||||
table := table.new_table()
|
table := table.new_table()
|
||||||
println(doc.doc(args[1], table, prefs))
|
println(doc.doc(mod, table, prefs))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else {}
|
else {}
|
||||||
|
|
|
@ -26,9 +26,19 @@ pub fn doc(mod string, table &table.Table, prefs &pref.Preferences) string {
|
||||||
vlib_path := os.dir(pref.vexe_path()) + '/vlib'
|
vlib_path := os.dir(pref.vexe_path()) + '/vlib'
|
||||||
mod_path := mod.replace('.', os.path_separator)
|
mod_path := mod.replace('.', os.path_separator)
|
||||||
path := os.join_path(vlib_path, mod_path)
|
path := os.join_path(vlib_path, mod_path)
|
||||||
if !os.exists(path) {
|
if mod == '' || !os.exists(path) {
|
||||||
|
if mod != '' {
|
||||||
println('module "$mod" not found')
|
println('module "$mod" not found')
|
||||||
println(path)
|
}
|
||||||
|
println('\navailable modules:')
|
||||||
|
mut files := os.ls(vlib_path) or {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
files.sort()
|
||||||
|
for file in files {
|
||||||
|
println(file)
|
||||||
|
}
|
||||||
|
// println(path)
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
// vfiles := os.walk_ext(path, '.v')
|
// vfiles := os.walk_ext(path, '.v')
|
||||||
|
|
Loading…
Reference in New Issue