Add build/install/run commands to shenlong.
This commit is contained in:
23
src/main.rs
23
src/main.rs
@@ -14,16 +14,21 @@ fn main() {
|
||||
match args.next().as_ref().map(|arg| arg.as_str()) {
|
||||
Some("info") => println!("{:?}", project.info()),
|
||||
Some("where") => println!("{}", project.path().display()),
|
||||
Some("run") => {
|
||||
Command::new(args.next().unwrap())
|
||||
.args(args)
|
||||
.current_dir(project.path())
|
||||
.spawn()
|
||||
.expect("command failed to start")
|
||||
.wait()
|
||||
.expect("failed to wait on child");
|
||||
},
|
||||
Some("build") => execute_command_in_project(&project, project.project_type.build_command().into_iter()),
|
||||
Some("install") => execute_command_in_project(&project, project.project_type.install_command().into_iter()),
|
||||
Some("start") => execute_command_in_project(&project, project.project_type.run_command().into_iter()),
|
||||
Some("run") => execute_command_in_project(&project, args),
|
||||
Some(_) => println!("unrecognized command"),
|
||||
None => println!("{:?}", project)
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_command_in_project<C: Iterator<Item=String>>(project: &scouter::Project, mut command: C) {
|
||||
Command::new(command.next().unwrap())
|
||||
.args(command)
|
||||
.current_dir(project.path())
|
||||
.spawn()
|
||||
.expect("command failed to start")
|
||||
.wait()
|
||||
.expect("failed to wait on child");
|
||||
}
|
||||
|
Reference in New Issue
Block a user