Currently it can detect the current project, run a command from the current project's root, and print the absolute path of the project.
30 lines
935 B
Rust
30 lines
935 B
Rust
use std::env;
|
|
use std::path::Path;
|
|
use scouter::Scouter;
|
|
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
let path = Path::new(".").canonicalize().expect("failed to canonicalize path");
|
|
let mut scouter = Scouter::new(path);
|
|
let project = scouter.next().expect("No supported project found");
|
|
|
|
let mut args = env::args();
|
|
args.next();
|
|
match args.next().as_ref().map(|arg| arg.as_str()) {
|
|
Some("info") => println!("{:?}", project),
|
|
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(_) => println!("unrecognized command"),
|
|
None => println!("{:?}", project)
|
|
}
|
|
}
|