Bash tool
This commit is contained in:
48
src/tool/mod.rs
Normal file
48
src/tool/mod.rs
Normal 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>,
|
||||
}
|
Reference in New Issue
Block a user