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:
parent
a08eb9cd8a
commit
b3a26ca0ce
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user