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

v.pref: make passing multiple target .v files an error (#8814)

This commit is contained in:
zakuro 2021-02-18 16:42:00 +09:00 committed by GitHub
parent a08eb9cd8a
commit b3a26ca0ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -400,7 +400,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
i++
}
else {
if command == 'build' && (arg.ends_with('.v') || os.exists(command)) {
if command == 'build' && is_source_file(arg) {
eprintln('Use `v $arg` instead.')
exit(1)
}
@ -417,6 +417,9 @@ pub fn parse_args(args []string) (&Preferences, string) {
if command == 'run' {
break
}
} else if is_source_file(command) && is_source_file(arg) {
eprintln('Too many targets. Specify just one target: <target.v|target_directory>.')
exit(1)
}
continue
}
@ -440,7 +443,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
eprintln('Cannot save output binary in a .v file.')
exit(1)
}
if command.ends_with('.v') || os.exists(command) {
if is_source_file(command) {
res.path = command
} else if command == 'run' {
res.is_run = true
@ -515,6 +518,11 @@ fn must_exist(path string) {
}
}
[inline]
fn is_source_file(path string) bool {
return path.ends_with('.v') || os.exists(path)
}
pub fn backend_from_string(s string) ?Backend {
match s {
'c' { return .c }