add ability to specify multiple commands
This commit is contained in:
parent
708f8d6388
commit
962425c515
@ -20,7 +20,23 @@ pub struct Settings {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub cache: Cache,
|
pub cache: Cache,
|
||||||
|
|
||||||
pub post_update_command: Option<String>,
|
pub post_update_command: Option<PostUpdateCommand>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
|
#[serde(untagged)]
|
||||||
|
pub enum PostUpdateCommand {
|
||||||
|
Single(String),
|
||||||
|
Multiple(Vec<String>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PostUpdateCommand {
|
||||||
|
pub fn get_commands(&self) -> Vec<String> {
|
||||||
|
match self.clone() {
|
||||||
|
PostUpdateCommand::Single(item) => vec![item],
|
||||||
|
PostUpdateCommand::Multiple(items) => items,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
|
#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
|
@ -13,7 +13,8 @@ impl CustomCommand {
|
|||||||
|
|
||||||
pub async fn execute_post_update_command(&self, path: &Path) -> anyhow::Result<()> {
|
pub async fn execute_post_update_command(&self, path: &Path) -> anyhow::Result<()> {
|
||||||
if let Some(post_update_command) = &self.config.settings.post_update_command {
|
if let Some(post_update_command) = &self.config.settings.post_update_command {
|
||||||
let command_parts = post_update_command.split(' ').collect::<Vec<_>>();
|
for command in post_update_command.get_commands() {
|
||||||
|
let command_parts = command.split(' ').collect::<Vec<_>>();
|
||||||
let Some((first, rest)) = command_parts.split_first() else {
|
let Some((first, rest)) = command_parts.split_first() else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
@ -21,9 +22,11 @@ impl CustomCommand {
|
|||||||
let mut cmd = tokio::process::Command::new(first);
|
let mut cmd = tokio::process::Command::new(first);
|
||||||
cmd.args(rest).current_dir(path);
|
cmd.args(rest).current_dir(path);
|
||||||
|
|
||||||
|
eprintln!("running command: {}", command);
|
||||||
|
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
path = path.display().to_string(),
|
path = path.display().to_string(),
|
||||||
cmd = post_update_command,
|
cmd = command,
|
||||||
"running custom post update command"
|
"running custom post update command"
|
||||||
);
|
);
|
||||||
let output = cmd.output().await?;
|
let output = cmd.output().await?;
|
||||||
@ -33,6 +36,7 @@ impl CustomCommand {
|
|||||||
"finished running custom post update command"
|
"finished running custom post update command"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user