v.pref: make passing multiple target .v files an error (#8814)
parent
a08eb9cd8a
commit
b3a26ca0ce
vlib/v/pref
|
@ -400,7 +400,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if command == 'build' && (arg.ends_with('.v') || os.exists(command)) {
|
if command == 'build' && is_source_file(arg) {
|
||||||
eprintln('Use `v $arg` instead.')
|
eprintln('Use `v $arg` instead.')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
@ -417,6 +417,9 @@ pub fn parse_args(args []string) (&Preferences, string) {
|
||||||
if command == 'run' {
|
if command == 'run' {
|
||||||
break
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
@ -440,7 +443,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
|
||||||
eprintln('Cannot save output binary in a .v file.')
|
eprintln('Cannot save output binary in a .v file.')
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
if command.ends_with('.v') || os.exists(command) {
|
if is_source_file(command) {
|
||||||
res.path = command
|
res.path = command
|
||||||
} else if command == 'run' {
|
} else if command == 'run' {
|
||||||
res.is_run = true
|
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 {
|
pub fn backend_from_string(s string) ?Backend {
|
||||||
match s {
|
match s {
|
||||||
'c' { return .c }
|
'c' { return .c }
|
||||||
|
|
Loading…
Reference in New Issue