49 lines
1.1 KiB
Rust
49 lines
1.1 KiB
Rust
use anyhow::Result;
|
|
use serde::{de::DeserializeOwned, Deserialize};
|
|
use std::{
|
|
fmt::Debug,
|
|
path::{Path, PathBuf},
|
|
};
|
|
|
|
mod bash;
|
|
pub use bash::*;
|
|
|
|
use crate::manifest::types::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, Clone)]
|
|
pub struct ToolConfig {
|
|
#[serde(default)]
|
|
pub bash: Option<ToolBash>,
|
|
}
|