Skip to main content

dampen_cli/commands/
release.rs

1#![allow(clippy::print_stderr, clippy::print_stdout)]
2
3//! Release command - builds production-optimized binaries with codegen mode
4//!
5//! This command wraps `cargo build --release` with the `codegen` feature flag,
6//! providing optimized production builds with zero runtime overhead.
7
8/// Release command arguments
9#[derive(clap::Args)]
10pub struct ReleaseArgs {
11    /// Package to build (if workspace has multiple packages)
12    #[arg(short, long)]
13    package: Option<String>,
14
15    /// Additional features to enable (beyond codegen)
16    #[arg(long, value_delimiter = ',')]
17    features: Vec<String>,
18
19    /// Verbose output
20    #[arg(short, long)]
21    verbose: bool,
22
23    /// Target directory for build artifacts
24    #[arg(long)]
25    target_dir: Option<String>,
26}
27
28/// Execute the release command
29///
30/// This is an alias for `dampen build --release` that builds the application
31/// in production mode with codegen and full optimizations.
32///
33/// # Mode Behavior
34///
35/// - **Release Mode**: Compile-time code generation with full optimizations
36/// - Zero runtime overhead for maximum performance
37/// - Ideal for production deployments
38/// - Requires build.rs for code generation
39///
40/// # Examples
41///
42/// ```bash
43/// # Basic release build (codegen)
44/// dampen release
45///
46/// # Build specific package in workspace
47/// dampen release -p my-app
48///
49/// # Enable additional features
50/// dampen release --features tokio,logging
51///
52/// # Custom target directory
53/// dampen release --target-dir ./dist
54///
55/// # Note: This is equivalent to `dampen build --release`
56/// ```
57pub fn execute(args: &ReleaseArgs) -> Result<(), String> {
58    // Note: This is an alias for dampen build --release
59    // Delegate to build module's release function
60
61    if args.verbose {
62        eprintln!("'dampen release' is an alias for 'dampen build --release'");
63    }
64
65    crate::commands::build::execute_release_build(
66        args.package.clone(),
67        args.features.clone(),
68        args.verbose,
69        args.target_dir.clone(),
70    )
71}