cmd/v: fix processing arguments

pull/4451/head
Alexey 2020-04-16 20:41:24 +03:00 committed by GitHub
parent aed8370d87
commit 663c69305a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -33,7 +33,7 @@ const (
) )
fn main() { fn main() {
args := util.join_env_vflags_and_os_args()[1..] args := os.args[1..]
//args = 123 //args = 123
if args.len == 0 || args[0] in ['-', 'repl'] { if args.len == 0 || args[0] in ['-', 'repl'] {
// Running `./v` without args launches repl // Running `./v` without args launches repl
@ -43,13 +43,13 @@ fn main() {
util.launch_tool(false, 'vrepl') util.launch_tool(false, 'vrepl')
return return
} }
os_args := os.args[1..] if args.len > 0 && (args[0] in ['version', '-V', '-version', '--version'] || (args[0] == '-v' && args.len == 1) ) {
if os_args.len > 0 && (os_args[0] in ['version', '-V', '-version', '--version'] || (os_args[0] == '-v' && os_args.len == 1) ) {
// `-v` flag is for setting verbosity, but without any args it prints the version, like Clang // `-v` flag is for setting verbosity, but without any args it prints the version, like Clang
println(util.full_v_version()) println(util.full_v_version())
return return
} }
prefs, command := parse_args(args) args_and_flags := util.join_env_vflags_and_os_args()[1..]
prefs, command := parse_args(args_and_flags)
if prefs.is_verbose { if prefs.is_verbose {
println('command = "$command"') println('command = "$command"')
println(util.full_v_version()) println(util.full_v_version())
@ -100,10 +100,6 @@ fn main() {
println(doc.doc(args[1], table)) println(doc.doc(args[1], table))
return return
} }
'help' {
invoke_help_and_exit(args)
return
}
else {} else {}
} }
if command in ['run', 'build-module'] || command.ends_with('.v') || os.exists(command) { if command in ['run', 'build-module'] || command.ends_with('.v') || os.exists(command) {