it works
This commit is contained in:
commit
ed55d5b489
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
16
Cargo.lock
generated
Normal file
16
Cargo.lock
generated
Normal file
@ -0,0 +1,16 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
||||
|
||||
[[package]]
|
||||
name = "cargo-gg"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
]
|
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "cargo-gg"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.95"
|
32
src/main.rs
Normal file
32
src/main.rs
Normal file
@ -0,0 +1,32 @@
|
||||
use std::{env, fs::File, process::Command};
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let mut arg_iter = env::args().peekable();
|
||||
arg_iter.next();
|
||||
|
||||
if arg_iter.peek().map_or(false, |arg| arg == "gg") {
|
||||
let _ = arg_iter.next();
|
||||
}
|
||||
|
||||
let args: Vec<_> = arg_iter.collect();
|
||||
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.args(args);
|
||||
|
||||
let status = cmd.status()?;
|
||||
let code = status.code().unwrap_or(1);
|
||||
|
||||
let path = env::temp_dir().join(".gg-failed");
|
||||
|
||||
if code == 0 {
|
||||
if std::fs::exists(&path)? {
|
||||
println!("Good girl!");
|
||||
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
} else {
|
||||
let _ = File::create(env::temp_dir().join(".gg-failed"));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in New Issue
Block a user