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:
parent
02fc58d124
commit
2029d1830f
@ -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)
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import os
|
|||||||
import os.cmdline
|
import os.cmdline
|
||||||
import rand
|
import rand
|
||||||
import term
|
import term
|
||||||
import vhelp
|
import v.help
|
||||||
import regex
|
import regex
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -43,7 +43,7 @@ fn (v1 CheckResult) + (v2 CheckResult) CheckResult {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if non_option_args.len == 0 || '-help' in os.args {
|
if non_option_args.len == 0 || '-help' in os.args {
|
||||||
vhelp.show_topic('check-md')
|
help.print_and_exit('check-md')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if '-all' in os.args {
|
if '-all' in os.args {
|
||||||
|
@ -13,7 +13,7 @@ import v.fmt
|
|||||||
import v.util
|
import v.util
|
||||||
import v.util.diff
|
import v.util.diff
|
||||||
import v.parser
|
import v.parser
|
||||||
import vhelp
|
import v.help
|
||||||
|
|
||||||
struct FormatOptions {
|
struct FormatOptions {
|
||||||
is_l bool
|
is_l bool
|
||||||
@ -88,7 +88,7 @@ fn main() {
|
|||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if files.len == 0 || '-help' in args || '--help' in args {
|
if files.len == 0 || '-help' in args || '--help' in args {
|
||||||
vhelp.show_topic('fmt')
|
help.print_and_exit('fmt')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
mut cli_args_no_files := []string{}
|
mut cli_args_no_files := []string{}
|
||||||
|
@ -9,7 +9,7 @@ import os.cmdline
|
|||||||
import net.http
|
import net.http
|
||||||
import net.urllib
|
import net.urllib
|
||||||
import json
|
import json
|
||||||
import vhelp
|
import v.help
|
||||||
import v.vmod
|
import v.vmod
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -139,7 +139,7 @@ fn main() {
|
|||||||
fn vpm_search(keywords []string) {
|
fn vpm_search(keywords []string) {
|
||||||
search_keys := keywords.map(it.replace('_', '-'))
|
search_keys := keywords.map(it.replace('_', '-'))
|
||||||
if settings.is_help {
|
if settings.is_help {
|
||||||
vhelp.show_topic('search')
|
help.print_and_exit('search')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if search_keys.len == 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) {
|
fn vpm_install(module_names []string, source Source) {
|
||||||
if settings.is_help {
|
if settings.is_help {
|
||||||
vhelp.show_topic('install')
|
help.print_and_exit('install')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if module_names.len == 0 {
|
if module_names.len == 0 {
|
||||||
@ -378,7 +378,7 @@ fn vpm_install(module_names []string, source Source) {
|
|||||||
fn vpm_update(m []string) {
|
fn vpm_update(m []string) {
|
||||||
mut module_names := m.clone()
|
mut module_names := m.clone()
|
||||||
if settings.is_help {
|
if settings.is_help {
|
||||||
vhelp.show_topic('update')
|
help.print_and_exit('update')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if module_names.len == 0 {
|
if module_names.len == 0 {
|
||||||
@ -479,7 +479,7 @@ fn vpm_list() {
|
|||||||
|
|
||||||
fn vpm_remove(module_names []string) {
|
fn vpm_remove(module_names []string) {
|
||||||
if settings.is_help {
|
if settings.is_help {
|
||||||
vhelp.show_topic('remove')
|
help.print_and_exit('remove')
|
||||||
exit(0)
|
exit(0)
|
||||||
}
|
}
|
||||||
if module_names.len == 0 {
|
if module_names.len == 0 {
|
||||||
@ -534,7 +534,7 @@ fn ensure_vmodules_dir_exist() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn vpm_help() {
|
fn vpm_help() {
|
||||||
vhelp.show_topic('vpm')
|
help.print_and_exit('vpm')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vcs_used_in_dir(dir string) ?[]string {
|
fn vcs_used_in_dir(dir string) ?[]string {
|
||||||
|
@ -36,4 +36,5 @@ fn main() {
|
|||||||
|
|
||||||
cb.copy(url)
|
cb.copy(url)
|
||||||
println(url)
|
println(url)
|
||||||
|
println('Copied URL to clipboard.')
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
module help
|
module help
|
||||||
|
|
||||||
// TODO: move this file outside internal, and merge it with cmd/tools/modules/vhelp/vhelp.v .
|
|
||||||
import os
|
import os
|
||||||
import v.pref
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
unknown_topic = '`v help`: unknown help topic provided. Use `v help` for usage information.'
|
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
|
// print_and_exit Prints the help topic and exits
|
||||||
pub fn print_and_exit(topic string) {
|
pub fn print_and_exit(topic string) {
|
||||||
vexe := pref.vexe_path()
|
vexe := @VEXE
|
||||||
vroot := os.dir(vexe)
|
vroot := os.dir(vexe)
|
||||||
topicdir := os.join_path(vroot, 'vlib', 'v', 'help')
|
topicdir := os.join_path(vroot, 'vlib', 'v', 'help')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user