Bash tool

This commit is contained in:
2025-05-03 11:24:34 -07:00
parent 20bf33fa05
commit 00c88ccf51
12 changed files with 1286 additions and 152 deletions

48
src/tool/mod.rs Normal file
View File

@ -0,0 +1,48 @@
use anyhow::Result;
use serde::{Deserialize, de::DeserializeOwned};
use std::{
fmt::Debug,
path::{Path, PathBuf},
};
mod bash;
pub use bash::*;
use crate::manifest::PickConfig;
pub trait PickTool: Debug + DeserializeOwned {
/// Runs once, before all tasks
fn before(&self, manifest_path: &Path, cfg: &PickConfig) -> Result<()>;
/// Runs once, after all tasks
fn after(&self, manifest_path: &Path, cfg: &PickConfig) -> Result<()>;
/// Runs once per task
fn run(&self, manifest_path: &Path, cfg: &PickConfig, ctx: TaskContext) -> Result<()>;
}
#[derive(Debug, Clone)]
/// All the information available when running a task
pub struct TaskContext {
/// The task to run
pub task: String,
/// The absolute path of the file we're processing
pub path_abs: PathBuf,
/// `self.path_abs` as a string
pub path_abs_str: String,
/// The path of the file we're processing,
/// relative to our working directory.
pub path_rel: PathBuf,
/// `self.path_rel`` as a string
pub path_rel_str: String,
}
#[derive(Debug, Deserialize)]
pub struct ToolConfig {
#[serde(default)]
pub bash: Option<ToolBash>,
}