mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
pref: error if unknown argument passed to v (#6487)
This commit is contained in:
@@ -147,7 +147,13 @@ pub fn parse_args(args []string) (&Preferences, string) {
|
||||
res.only_check_syntax = true
|
||||
}
|
||||
'-v' {
|
||||
res.is_verbose = true
|
||||
// `-v` flag is for setting verbosity, but without any args it prints the version, like Clang
|
||||
if args.len > 1 {
|
||||
res.is_verbose = true
|
||||
} else {
|
||||
command = 'version'
|
||||
command_pos = i
|
||||
}
|
||||
}
|
||||
'-silent' {
|
||||
res.output_mode = .silent
|
||||
@@ -313,21 +319,31 @@ pub fn parse_args(args []string) (&Preferences, string) {
|
||||
i++
|
||||
}
|
||||
else {
|
||||
mut should_continue := false
|
||||
for flag_with_param in list_of_flags_with_param {
|
||||
if '-$flag_with_param' == arg {
|
||||
should_continue = true
|
||||
if arg[0] == `-` {
|
||||
if arg[1..] in list_of_flags_with_param {
|
||||
// skip parameter
|
||||
i++
|
||||
break
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if command == '' {
|
||||
command = arg
|
||||
command_pos = i
|
||||
}
|
||||
}
|
||||
if should_continue {
|
||||
continue
|
||||
}
|
||||
if !arg.starts_with('-') && command == '' {
|
||||
command = arg
|
||||
if arg in ['-V', '-version', '--version'] {
|
||||
command = 'version'
|
||||
command_pos = i
|
||||
continue
|
||||
}
|
||||
if command !in ['', 'run', 'build', 'build-module'] {
|
||||
// arguments for e.g. fmt are checked elsewhere
|
||||
continue
|
||||
}
|
||||
eprint('Unknown argument `$arg`')
|
||||
eprintln(if command.len == 0 {''} else {' for command `$command`'})
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user