diff --git a/cmd/tools/modules/vhelp/vhelp.v b/cmd/tools/modules/vhelp/vhelp.v deleted file mode 100644 index 2b7cd9de5d..0000000000 --- a/cmd/tools/modules/vhelp/vhelp.v +++ /dev/null @@ -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) -} diff --git a/cmd/tools/vcheck-md.v b/cmd/tools/vcheck-md.v index 3f66eff7c7..539fc6a3f8 100644 --- a/cmd/tools/vcheck-md.v +++ b/cmd/tools/vcheck-md.v @@ -7,7 +7,7 @@ import os import os.cmdline import rand import term -import vhelp +import v.help import regex const ( @@ -43,7 +43,7 @@ fn (v1 CheckResult) + (v2 CheckResult) CheckResult { fn main() { if non_option_args.len == 0 || '-help' in os.args { - vhelp.show_topic('check-md') + help.print_and_exit('check-md') exit(0) } if '-all' in os.args { diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v index a50937e214..bd15da6407 100644 --- a/cmd/tools/vfmt.v +++ b/cmd/tools/vfmt.v @@ -13,7 +13,7 @@ import v.fmt import v.util import v.util.diff import v.parser -import vhelp +import v.help struct FormatOptions { is_l bool @@ -88,7 +88,7 @@ fn main() { exit(0) } if files.len == 0 || '-help' in args || '--help' in args { - vhelp.show_topic('fmt') + help.print_and_exit('fmt') exit(0) } mut cli_args_no_files := []string{} diff --git a/cmd/tools/vpm.v b/cmd/tools/vpm.v index 00a1272402..dfa76c4f05 100644 --- a/cmd/tools/vpm.v +++ b/cmd/tools/vpm.v @@ -9,7 +9,7 @@ import os.cmdline import net.http import net.urllib import json -import vhelp +import v.help import v.vmod const ( @@ -139,7 +139,7 @@ fn main() { fn vpm_search(keywords []string) { search_keys := keywords.map(it.replace('_', '-')) if settings.is_help { - vhelp.show_topic('search') + help.print_and_exit('search') exit(0) } if search_keys.len == 0 { @@ -355,7 +355,7 @@ fn vpm_once_filter(module_names []string) []string { fn vpm_install(module_names []string, source Source) { if settings.is_help { - vhelp.show_topic('install') + help.print_and_exit('install') exit(0) } if module_names.len == 0 { @@ -378,7 +378,7 @@ fn vpm_install(module_names []string, source Source) { fn vpm_update(m []string) { mut module_names := m.clone() if settings.is_help { - vhelp.show_topic('update') + help.print_and_exit('update') exit(0) } if module_names.len == 0 { @@ -479,7 +479,7 @@ fn vpm_list() { fn vpm_remove(module_names []string) { if settings.is_help { - vhelp.show_topic('remove') + help.print_and_exit('remove') exit(0) } if module_names.len == 0 { @@ -534,7 +534,7 @@ fn ensure_vmodules_dir_exist() { } fn vpm_help() { - vhelp.show_topic('vpm') + help.print_and_exit('vpm') } fn vcs_used_in_dir(dir string) ?[]string { diff --git a/cmd/tools/vshare.v b/cmd/tools/vshare.v index 9bf02ac89a..a45ed4f5a4 100644 --- a/cmd/tools/vshare.v +++ b/cmd/tools/vshare.v @@ -36,4 +36,5 @@ fn main() { cb.copy(url) println(url) + println('Copied URL to clipboard.') } diff --git a/vlib/v/help/help.v b/vlib/v/help/help.v index 2abcbcdfab..aa0ab15fa7 100644 --- a/vlib/v/help/help.v +++ b/vlib/v/help/help.v @@ -1,8 +1,6 @@ module help -// TODO: move this file outside internal, and merge it with cmd/tools/modules/vhelp/vhelp.v . import os -import v.pref const ( unknown_topic = '`v help`: unknown help topic provided. Use `v help` for usage information.' @@ -10,7 +8,7 @@ const ( // print_and_exit Prints the help topic and exits pub fn print_and_exit(topic string) { - vexe := pref.vexe_path() + vexe := @VEXE vroot := os.dir(vexe) topicdir := os.join_path(vroot, 'vlib', 'v', 'help')