Skip to content

Commit

Permalink
refactor(ssg): 🎨 refactoring structure and simplifying overall code
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Nov 10, 2024
1 parent 0275a28 commit f201a7b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 47 deletions.
12 changes: 5 additions & 7 deletions src/cmd/cli.rs → src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

//! # Command Line Interface Module
//!
//! This module provides a secure and robust command-line interface for the Shokunin
//! Static Site Generator. It handles argument parsing, configuration management,
//! and validation of user inputs.
//! This module provides a secure and robust command-line interface for the Shokunin Static Site Generator. It handles argument parsing, configuration management, and validation of user inputs.
//!
//! ## Key Features
//!
Expand All @@ -18,8 +16,8 @@
//!
//! ## Example Usage
//! ```rust,no_run
//! use ssg::cmd::cli::build;
//! use ssg::cmd::cli::ShokuninConfig;
//! use ssg::cli::build;
//! use ssg::cli::ShokuninConfig;
//!
//! fn main() -> anyhow::Result<()> {
//! // Initialize the CLI with arguments from `build()`
Expand Down Expand Up @@ -85,7 +83,7 @@ pub enum CliError {
/// # Example
///
/// ```rust,no_run
/// use ssg::cmd::cli::ShokuninConfig;
/// use ssg::cli::ShokuninConfig;
/// use std::path::PathBuf;
///
/// let config = ShokuninConfig {
Expand Down Expand Up @@ -154,7 +152,7 @@ impl ShokuninConfig {
/// # Example
///
/// ```rust,no_run
/// use ssg::cmd::cli::{build, ShokuninConfig};
/// use ssg::cli::{build, ShokuninConfig};
///
/// let matches = build().get_matches();
/// let config = ShokuninConfig::from_matches(&matches).unwrap();
Expand Down
35 changes: 0 additions & 35 deletions src/cmd/mod.rs

This file was deleted.

11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ use staticdatagen::{
};

/// Module declarations
pub mod cmd;

/// Process module for handling site generation
pub mod process;

/// CLI module for command-line interface
pub mod cli;

/// Re-exports
pub use staticdatagen;
Expand Down Expand Up @@ -130,11 +135,11 @@ pub fn run() -> Result<()> {
.context("Failed to create log file")?;

// Display banner and log initialization
cmd::cli::print_banner();
cli::print_banner();
log_initialization(&mut log_file, &date)?;

Check warning on line 139 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L138-L139

Added lines #L138 - L139 were not covered by tests

// Parse command-line arguments
let matches = cmd::cli::build().get_matches();
let matches = cli::build().get_matches();

Check warning on line 142 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L142

Added line #L142 was not covered by tests
log_arguments(&mut log_file, &date)?;

// Extract and validate paths
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/process.rs → src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub enum ProcessError {
///
/// ```rust,no_run
/// # use clap::{ArgMatches, Command};
/// # use ssg::cmd::process::get_argument;
/// # use ssg::process::get_argument;
/// let matches = Command::new("test")
/// .arg(clap::arg!(--"config" <CONFIG> "Specifies the configuration file"))
/// .get_matches_from(vec!["test", "--config", "path/to/config.toml"]);
Expand Down Expand Up @@ -96,7 +96,7 @@ pub fn get_argument(
///
/// ```rust,no_run
/// # use std::path::Path;
/// # use ssg::cmd::process::ensure_directory;
/// # use ssg::process::ensure_directory;
/// let path = Path::new("path/to/output");
/// ensure_directory(path, "output").expect("Failed to ensure directory exists");
/// ```
Expand Down

0 comments on commit f201a7b

Please sign in to comment.