1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: remove cmd/tools/modules/vhelp/ & add print to v share (#17178)

This commit is contained in:
Christopher Fore
2023-02-01 04:18:23 -05:00
committed by GitHub
parent 02fc58d124
commit 2029d1830f
6 changed files with 12 additions and 54 deletions

View File

@@ -1,41 +0,0 @@
module vhelp
import os
pub fn show_topic(topic string) {
vexe := os.real_path(os.getenv('VEXE'))
vroot := os.dir(vexe)
topicdir := os.join_path(vroot, 'vlib', 'v', 'help')
mut path_to := topic
mut topics := os.walk_ext(topicdir, '.txt')
mut items := [][]string{}
// Getting the directory, splitting at `/`, reversing,
// trimming to only indexes 0 and 1, and reversing that into the items array
for mut item in topics {
mut item_rev := item.split('/').reverse()
item_rev.trim(2)
items << item_rev.reverse()
}
// Getting the path to the help topic text file
for cmds in items {
if '${topic}.txt' in cmds {
path_to = '${cmds[0]}/${cmds[1].replace('.txt', '')}'
break
}
}
topic_dir := if topic == 'default' {
os.join_path(topicdir, 'default.txt')
} else {
os.join_path(topicdir, '${path_to}.txt')
}
content := os.read_file(topic_dir) or {
eprintln('Unknown topic: ${topic}')
exit(1)
}
println(content)
}