From e412204a498e2cf7f43fdea575f27dc0d5e869d9 Mon Sep 17 00:00:00 2001 From: theMackabu Date: Wed, 15 Nov 2023 19:40:33 -0800 Subject: [PATCH] get name from script --- Maidfile.toml | 7 +++++++ src/cli.rs | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Maidfile.toml b/Maidfile.toml index d8f13a5..1737bb3 100644 --- a/Maidfile.toml +++ b/Maidfile.toml @@ -11,3 +11,10 @@ script = [ "cargo zigbuild --release", "cp target/release/pmc bin/pmc" ] + +[tasks.install] +script = [ + "maid build -q", + "sudo cp bin/pmc /usr/local/bin", + "echo Copied binary!" +] diff --git a/src/cli.rs b/src/cli.rs index fb7cd26..32cb63d 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -29,11 +29,6 @@ pub fn get_version(short: bool) -> String { pub fn start(name: &Option, args: &Option) { let mut runner = Runner::new(global!("pmc.logs")); - let name = match name { - Some(name) => string!(name), - None => string!(""), - }; - match args { Some(Args::Id(id)) => { println!("{} Applying action restartProcess on ({id})", *helpers::SUCCESS); @@ -43,6 +38,11 @@ pub fn start(name: &Option, args: &Option) { list(&string!("")); } Some(Args::Script(script)) => { + let name = match name { + Some(name) => string!(name), + None => string!(script.split_whitespace().next().unwrap_or_default()), + }; + println!("{} Creating process with ({name})", *helpers::SUCCESS); runner.start(name.clone(), script); -- GitLab