BoilerplateManager

Struct BoilerplateManager 

Source
pub struct BoilerplateManager;
Expand description

Manages boilerplate operations: loading, validation, and application

Implements requirements:

  • Requirement 3.1: Load and parse boilerplate definitions
  • Requirement 3.2: Validate boilerplate before application
  • Requirement 3.3: Prompt for variable customization
  • Requirement 3.4: Handle file conflicts (skip/overwrite/merge)
  • Requirement 3.5: Support custom boilerplate creation
  • Requirement 3.6: Validate boilerplate structure

Implementations§

Source§

impl BoilerplateManager

Source

pub fn new() -> Self

Create a new boilerplate manager

Source

pub fn load( &self, boilerplate_path: &Path, ) -> Result<Boilerplate, BoilerplateError>

Load a boilerplate from a directory

Parses the boilerplate metadata and validates the structure.

§Arguments
  • boilerplate_path - Path to the boilerplate directory
§Returns

Loaded boilerplate or error

§Requirements
  • Requirement 3.1: Load and parse boilerplate definitions
  • Requirement 3.2: Validate boilerplate before application
Source

pub fn load_by_name( &self, project_root: &Path, boilerplate_name: &str, ) -> Result<Boilerplate, BoilerplateError>

Load a boilerplate by name from discovery

Searches for the boilerplate in project and global scopes.

§Arguments
  • project_root - Root directory of the project
  • boilerplate_name - Name of the boilerplate to load
§Returns

Loaded boilerplate or error

Source

pub fn validate( &self, boilerplate: &Boilerplate, ) -> Result<(), BoilerplateError>

Validate a boilerplate structure

Checks that the boilerplate has required fields and valid structure.

§Arguments
  • boilerplate - Boilerplate to validate
§Returns

Ok if valid, error otherwise

§Requirements
  • Requirement 3.2: Validate boilerplate before application
Source

pub fn extract_placeholders( &self, boilerplate: &Boilerplate, ) -> Result<HashMap<String, String>, BoilerplateError>

Extract placeholders from a boilerplate

Scans all template files in the boilerplate and extracts required placeholders.

§Arguments
  • boilerplate - Boilerplate to scan
§Returns

Map of placeholder names to descriptions

Source

pub fn apply( &self, boilerplate: &Boilerplate, target_dir: &Path, variables: &HashMap<String, String>, conflict_resolution: ConflictResolution, ) -> Result<ScaffoldingResult, BoilerplateError>

Apply a boilerplate to create a new project

Creates the project structure from the boilerplate, rendering templates with provided values.

§Arguments
  • boilerplate - Boilerplate to apply
  • target_dir - Directory where to create the project
  • variables - Variable values for template substitution
  • conflict_resolution - How to handle file conflicts
§Returns

Result of scaffolding operation

§Requirements
  • Requirement 3.1: Create project structure from boilerplate
  • Requirement 3.3: Render template files with context
  • Requirement 3.4: Handle file conflicts (skip/overwrite/merge)
Source

pub fn create_custom( &self, source_dir: &Path, boilerplate_id: &str, boilerplate_name: &str, language: &str, ) -> Result<Boilerplate, BoilerplateError>

Create a custom boilerplate from a template

Generates a new boilerplate definition from a template directory.

§Arguments
  • source_dir - Directory containing the template files
  • boilerplate_id - ID for the new boilerplate
  • boilerplate_name - Name for the new boilerplate
  • language - Programming language
§Returns

Created boilerplate or error

§Requirements
  • Requirement 3.5: Support custom boilerplate creation
Source

pub fn save( &self, boilerplate: &Boilerplate, target_dir: &Path, ) -> Result<(), BoilerplateError>

Save a boilerplate to disk

Writes the boilerplate metadata and files to a directory.

§Arguments
  • boilerplate - Boilerplate to save
  • target_dir - Directory where to save the boilerplate
§Returns

Ok if successful, error otherwise

Trait Implementations§

Source§

impl Default for BoilerplateManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more