pub fn execute(args: &AddArgs) -> Result<(), String>Expand description
Execute the add command.
This generates UI window files based on validated inputs.
§Process
- Detect project: Validates this is a Dampen project
- Validate name: Checks window name is valid identifier
- Resolve path: Determines output directory (default or custom)
- Generate files: Creates .rs and .dampen files from templates
- Report success: Shows file paths and next steps
§Errors
Returns Err(String) if:
- Not in a Dampen project (no
dampen-corein Cargo.toml) - Window name is invalid (empty, starts with number, reserved keyword)
- Output path is invalid (absolute, escapes project)
- Files already exist (prevents overwriting)
- I/O errors occur during file creation
§Examples
use dampen_cli::commands::add::{AddArgs, execute};
let args = AddArgs {
ui: Some("settings".to_string()),
path: None,
no_integrate: false,
};
match execute(&args) {
Ok(()) => println!("Window created successfully"),
Err(e) => eprintln!("Error: {}", e),
}