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

cmd/v: implement help

This commit is contained in:
lutherwenxu
2020-03-14 03:52:49 +08:00
committed by GitHub
parent 920ab79665
commit c2ffd027d0
20 changed files with 384 additions and 209 deletions

View File

@ -11,6 +11,7 @@ import (
v.fmt
v.parser
v.table
vhelp
)
struct FormatOptions {
@ -93,7 +94,7 @@ fn main() {
files << file
}
if files.len == 0 {
usage()
vhelp.show_topic('fmt')
exit(0)
}
mut cli_args_no_files := []string
@ -295,22 +296,6 @@ fn (foptions &FormatOptions) post_process_file(file string, formatted_file_path
print(formatted_fc)
}
fn usage() {
print('Usage: cmd/tools/vfmt [flags] fmt path_to_source.v [path_to_other_source.v]
Formats the given V source files, and prints their formatted source to stdout.
Options:
-c check if file is already formatted.
If it is not, print filepath, and exit with code 2.
-diff display only diffs between the formatted source and the original source.
-l list files whose formatting differs from vfmt.
-w write result to (source) file(s) instead of to stdout.
-2 Use the new V parser/vfmt. NB: this is EXPERIMENTAL for now.
The new vfmt is much faster and more forgiving.
It also may EAT some of your code for now.
Please be careful, and make frequent BACKUPS, when running with -vfmt2 .
')
}
fn find_working_diff_command() ?string {
for diffcmd in ['colordiff', 'diff', 'colordiff.exe', 'diff.exe'] {
p := os.exec('$diffcmd --version') or {