Skip to main content

args

Function args 

Source
pub fn args(matches: &ArgMatches) -> Result<(), ProcessError>
Expand description

Processes CLI arguments and executes the corresponding site compilation workflow.

This function performs the following steps:

  1. Retrieves required directory paths from command-line arguments.
  2. Ensures each directory exists, creating it if necessary.
  3. Calls the compilation service to generate the static site.

§Arguments

  • matches - Parsed command-line arguments from clap.

§Returns

  • Result<(), ProcessError> - Returns Ok on successful completion, or an error if a problem occurs.

§Errors

  • Returns ProcessError::MissingArgument if a required argument is not provided.
  • Returns ProcessError::DirectoryCreation if a directory cannot be created.
  • Returns ProcessError::CompilationError if the site fails to compile.

§Examples

use clap::{Arg, Command};
use ssg::process::args;

// Missing required arguments ⇒ `MissingArgument` error.
let matches = Command::new("t")
    .arg(Arg::new("content").long("content"))
    .get_matches_from(vec!["t"]);
assert!(args(&matches).is_err());