sastri 0.1.0

Scaffold multi-ecosystem packaging and CI/CD for Rust CLIs (Homebrew, Scoop, PyPI, npm, Hex, mise, asdf, …)
Documentation
use std::path::Path;

use anyhow::Result;

use crate::config::SastriConfig;

/// Context passed to every mechanism during generate.
pub struct MechanismContext<'a> {
    pub config: &'a SastriConfig,
    /// Target repository root (where packaging/ and .github/ are written).
    pub root: &'a Path,
    pub force: bool,
}

/// A file the mechanism wants to write (relative to `root`).
#[derive(Debug, Clone)]
pub struct GeneratedFile {
    pub relative_path: String,
    pub contents: String,
    pub executable: bool,
}

#[derive(Debug, Clone)]
pub struct StepResult {
    pub files: Vec<GeneratedFile>,
    /// Human notes shown after generate (e.g. "create tap repo, set NPM_TOKEN").
    pub notes: Vec<String>,
}

/// One install / packaging channel (Homebrew, npm, RubyGems, …).
///
/// Mechanisms must be pure generators: no network, no secret values.
pub trait Mechanism: Send + Sync {
    /// Stable id used in `Sastri.toml` `[mechanisms]` and `--only`.
    fn id(&self) -> &'static str;

    fn description(&self) -> &'static str;

    /// `false` for stubs (Ruby, Haskell) until implemented.
    fn stable(&self) -> bool {
        true
    }

    /// Extra wizard questions when this mechanism is enabled.
    fn wizard_hints(&self) -> Vec<&'static str> {
        Vec::new()
    }

    fn generate(&self, ctx: &MechanismContext<'_>) -> Result<StepResult>;
}