v.pref: fix `v build file.v`
							parent
							
								
									6dd1494008
								
							
						
					
					
						commit
						14fd7d93ca
					
				| 
						 | 
				
			
			@ -34,7 +34,7 @@ V supports the following commands:
 | 
			
		|||
   list              List all installed modules.
 | 
			
		||||
   outdated          Show installed modules that need updates.
 | 
			
		||||
* Others:
 | 
			
		||||
   build             Build a V code in the provided path (the default, so you can skip the word `build`).
 | 
			
		||||
   build             Build V code in the provided path (the default, so you can skip the word `build`).
 | 
			
		||||
   translate         Translate C code to V (coming soon in 0.3).
 | 
			
		||||
   tracev            Produce a tracing version of the v compiler.
 | 
			
		||||
                     Use `tracev yourfile.v` when the compiler panics.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -87,7 +87,7 @@ fn main() {
 | 
			
		|||
		}
 | 
			
		||||
		else {}
 | 
			
		||||
	}
 | 
			
		||||
	if command in ['run', 'build-module'] || command.ends_with('.v') || os.exists(command) {
 | 
			
		||||
	if command in ['run', 'build', 'build-module'] || command.ends_with('.v') || os.exists(command) {
 | 
			
		||||
		// println('command')
 | 
			
		||||
		// println(prefs.path)
 | 
			
		||||
		builder.compile(command, prefs)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -310,6 +310,13 @@ pub fn parse_args(args []string) (&Preferences, string) {
 | 
			
		|||
	}
 | 
			
		||||
	if command.ends_with('.v') || os.exists(command) {
 | 
			
		||||
		res.path = command
 | 
			
		||||
	} else if command == 'build' {
 | 
			
		||||
		if command_pos + 2 != args.len {
 | 
			
		||||
			eprintln('`v build` requires exactly one argument - either a single .v file, or a single folder/ containing several .v files')
 | 
			
		||||
			exit(1)
 | 
			
		||||
		}
 | 
			
		||||
		res.path = args[command_pos + 1]
 | 
			
		||||
		must_exist(res.path)
 | 
			
		||||
	} else if command == 'run' {
 | 
			
		||||
		res.is_run = true
 | 
			
		||||
		if command_pos + 2 > args.len {
 | 
			
		||||
| 
						 | 
				
			
			@ -318,6 +325,7 @@ pub fn parse_args(args []string) (&Preferences, string) {
 | 
			
		|||
		}
 | 
			
		||||
		res.path = args[command_pos + 1]
 | 
			
		||||
		res.run_args = args[command_pos + 2..]
 | 
			
		||||
		must_exist(res.path)
 | 
			
		||||
	}
 | 
			
		||||
	if command == 'build-module' {
 | 
			
		||||
		res.build_mode = .build_module
 | 
			
		||||
| 
						 | 
				
			
			@ -327,6 +335,13 @@ pub fn parse_args(args []string) (&Preferences, string) {
 | 
			
		|||
	return res, command
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn must_exist(path string) {
 | 
			
		||||
	if !os.exists(path) {
 | 
			
		||||
		eprintln('v expects that `$path` exists, but it does not')
 | 
			
		||||
		exit(1)
 | 
			
		||||
	}        
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn backend_from_string(s string) ?Backend {
 | 
			
		||||
	match s {
 | 
			
		||||
		'c' { return .c }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue