Function start

Source
pub fn start(mode: &str) -> Result<(), GrimoireCssError>
Expand description

Starts the Grimoire CSS system based on the given mode, without performing any CLI-specific side effects.

This function determines the current working directory, initializes the LightningCSSOptimizer, and then processes the mode, invoking the appropriate command handlers.

§Arguments

  • mode - A string representing the mode of operation (e.g., “build”, “init”).

§Returns

  • Ok(()) - If the mode is processed successfully.
  • Err(GrimoireCSSError) - If there is an error during initialization or command execution.

§Errors

This function returns a GrimoireCSSError if the current directory cannot be determined, the optimizer initialization fails, or the mode processing encounters an error.

§Examples

use grimoire_css_lib::start;
if let Err(e) = start("build".to_string()) {
    eprintln!("Error: {e}");
}