Expand description
§Command Line Interface Module
This module provides a secure and robust command-line interface (CLI) for the Shokunin Static Site Generator. It handles argument parsing, configuration management, and validation of user inputs to ensure that the static site generator operates reliably and securely.
§Key Features
- Safe path handling (including symbolic link checks and canonicalization)
- Input validation (URL, language, environment variables)
- Secure configuration with size-limited config files
- Builder pattern for convenient configuration construction
- Error handling via
CliError
§Example Usage
use ssg::cmd::{Cli, ShokuninConfig};
fn main() -> anyhow::Result<()> {
let matches = Cli::build().get_matches();
// Attempt to load configuration from command-line arguments
let mut config = ShokuninConfig::from_matches(&matches)?;
println!("Configuration loaded: {:?}", config);
// Continue with application logic...
Ok(())
}
Structs§
- Cli
- A simple CLI struct for building the Shokunin command.
- Language
Code - Type-safe representation of a language code.
- Shokunin
Config - Core configuration for the static site generator.
- Shokunin
Config Builder - Builder for
ShokuninConfig
.
Enums§
- CliError
- Possible errors that can occur during CLI operations.
Constants§
- DEFAULT_
HOST - Default host for the local development server.
- DEFAULT_
PORT - Default port for the local development server.
- DEFAULT_
SITE_ NAME - Default site name for the configuration.
- DEFAULT_
SITE_ TITLE - Default site title for the configuration.
- MAX_
CONFIG_ SIZE - Maximum allowed size in bytes for config files.
- RESERVED_
NAMES - Reserved names that cannot be used as paths on Windows systems.
Statics§
- DEFAULT_
CONFIG - A static default configuration for the Shokunin site.
Functions§
- validate_
url - Validates a URL for security and format.