Function start_as_cli

Source
pub fn start_as_cli(args: Vec<String>) -> Result<(), GrimoireCssError>
Expand description

A convenience function that simulates CLI behavior (timing, logging, spinner) but is placed in the library crate to avoid duplicating code in multiple binaries or wrappers.

§Warning

  • This is not an idiomatic approach for a typical Rust library since it introduces console-based side effects.
  • If you do not want logs, spinners, or colorized output, do not call this function. Instead, call start directly.
  • This function depends on console and indicatif crates for styling and progress-bar support, which might not be desired in all contexts.

§Arguments

  • args - A vector of strings typically representing command-line arguments. The first argument is expected to be the binary name, and the second argument the mode (e.g. “build”, “init”).

§Returns

  • Ok(()) on success, or an Err(GrimoireCSSError) if invalid arguments or runtime issues occur.

§Examples

use grimoire_css_lib::start_as_cli;

// Typically used in a real CLI setup:
let args = vec!["grimoire_css".to_string(), "build".to_string()];
if let Err(err) = start_as_cli(args) {
    eprintln!("Failed: {err}");
}