From f0b1791c18a04e603f62a59bec6d74d7993cea19 Mon Sep 17 00:00:00 2001 From: blob42 Date: Wed, 2 Oct 2024 19:07:52 +0200 Subject: [PATCH] chore: cargo and comments --- Cargo.toml | 4 ++-- {src/bin => examples}/debug_process.rs | 0 {src/bin => examples}/proto_condition.rs | 0 src/config/profile.rs | 7 ------- src/sched.rs | 2 ++ 5 files changed, 4 insertions(+), 9 deletions(-) rename {src/bin => examples}/debug_process.rs (100%) rename {src/bin => examples}/proto_condition.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 64b2aa3..03d40c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,9 +5,9 @@ edition = "2021" default-run = "pswatch" -[[bin]] +[[example]] name = "condition" -path = "src/bin/proto_condition.rs" +path = "examples/proto_condition.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/bin/debug_process.rs b/examples/debug_process.rs similarity index 100% rename from src/bin/debug_process.rs rename to examples/debug_process.rs diff --git a/src/bin/proto_condition.rs b/examples/proto_condition.rs similarity index 100% rename from src/bin/proto_condition.rs rename to examples/proto_condition.rs diff --git a/src/config/profile.rs b/src/config/profile.rs index f354427..f75573c 100644 --- a/src/config/profile.rs +++ b/src/config/profile.rs @@ -10,17 +10,10 @@ pub struct Profile { /// pattern of process name to match against pub matching: ProcessMatcher, - // /// Where to match the process pattern (exe, cmdline, name) - // #[serde(default)] - // pub pattern_in: PatternIn, /// List of commands to run when condition is met pub commands: Vec, - /// Interpret `pattern` as regex - // #[serde(default)] - // pub regex: bool, - //TODO: // pub match_by: /// process watch sampling rate diff --git a/src/sched.rs b/src/sched.rs index ba16f4d..5071614 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -44,10 +44,12 @@ impl ProfileJob { fn run_cmd(cmd: &mut CmdSchedule, matching: ProcessMatcher, exec_end: bool) { + // handle end exec let out = if exec_end && cmd.exec_end.is_some() { Command::new(&cmd.exec_end.as_ref().unwrap()[0]).args(&cmd.exec_end.as_ref().unwrap()[1..]).output() } else if exec_end && cmd.exec_end.is_none() { return; + // run normal execs } else { Command::new(&cmd.exec[0]).args(&cmd.exec[1..]).output() };