Compare commits
4 Commits
afbcde5fd3
...
7f7d829c93
Author | SHA1 | Date | |
---|---|---|---|
|
7f7d829c93 | ||
|
a8c7cdf53b | ||
|
035560b881 | ||
|
b01a80f9a3 |
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -290,6 +290,10 @@ name = "scopeguard"
|
|||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scouter"
|
||||||
|
version = "0.0.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shenlong"
|
name = "shenlong"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
@ -297,6 +301,7 @@ dependencies = [
|
|||||||
"c_str_macro 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"c_str_macro 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"scouter 0.0.1",
|
||||||
"shenlong-sys 0.0.1",
|
"shenlong-sys 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ log = "0.4.6"
|
|||||||
env_logger = "0.6.0"
|
env_logger = "0.6.0"
|
||||||
shenlong-sys = { path = "shenlong-sys", version = "0.0.1" }
|
shenlong-sys = { path = "shenlong-sys", version = "0.0.1" }
|
||||||
c_str_macro = "1.0.2"
|
c_str_macro = "1.0.2"
|
||||||
|
scouter = { path = "scouter", version = "0.0.1" }
|
||||||
|
|
||||||
#[build-dependencies]
|
#[build-dependencies]
|
||||||
#cc = "1.0.28"
|
#cc = "1.0.28"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "scouter"
|
name = "scouter"
|
||||||
version = "0.1.0"
|
version = "0.0.1"
|
||||||
authors = ["Adrian Malacoda <adrian.malacoda@monarch-pass.net>"]
|
authors = ["Adrian Malacoda <adrian.malacoda@monarch-pass.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -29,9 +29,32 @@ pub struct Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Project {
|
impl Project {
|
||||||
fn path(&self) -> &Path {
|
pub fn path(&self) -> &Path {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn info(&self) -> ProjectInfo {
|
||||||
|
match self.project_type {
|
||||||
|
ProjectType::Maven => ProjectInfo {
|
||||||
|
name: "placeholder".into(),
|
||||||
|
version: "placeholder".into()
|
||||||
|
},
|
||||||
|
ProjectType::Npm => ProjectInfo {
|
||||||
|
name: "placeholder".into(),
|
||||||
|
version: "placeholder".into()
|
||||||
|
},
|
||||||
|
ProjectType::Cargo => ProjectInfo {
|
||||||
|
name: "placeholder".into(),
|
||||||
|
version: "placeholder".into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ProjectInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub version: String
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Scouter {
|
pub struct Scouter {
|
||||||
|
29
src/main.rs
Normal file
29
src/main.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
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.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(_) => println!("unrecognized command"),
|
||||||
|
None => println!("{:?}", project)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user