Repository navigation
Description
Parent Epic: #34 - Implement Create Environment Command
Depends On: #40 - Template System Integration
Status: OPTIONAL ENHANCEMENT
Estimated Time: 1-2 hours
⚠️ Note: This is an optional enhancement that can be deferred. It requires #40 (Template System Integration) to be completed first.
Overview
Implement the template subcommand for the create command, allowing users to generate configuration file templates. This enhances user experience by providing a starting point for configuration creation.
Goals
- Implement
templatesubcommand in the create command structure - Generate JSON configuration template files
- Support custom output paths for template generation
- Provide helpful placeholder content with clear replacement instructions
- Integrate with existing CLI subcommand architecture
Architecture Requirements
DDD Layer: Presentation (CLI interface) + Infrastructure (template generation)
Module Path: src/presentation/console/subcommands/create/ + src/infrastructure/templates/
Pattern: CLI Subcommand + Template Generation
Dependencies: Requires #40 (Template System Integration) to be completed first.
CLI Interface
# Generate template configuration file (JSON format)
torrust-tracker-deployer create template
# Creates: ./environment-template.json in current working directory
# Generate template in specific directory
torrust-tracker-deployer create template ./config/environment.json
# Generate template with custom filename
torrust-tracker-deployer create template ./my-environment.json
# Show help for template subcommand
torrust-tracker-deployer create template --helpTemplate Example
{
"environment": {
"name": "my-environment"
},
"ssh_credentials": {
"private_key_path": "~/.ssh/id_rsa",
"public_key_path": "~/.ssh/id_rsa.pub",
"username": "torrust",
"port": 22
}
}Acceptance Criteria
-
create templatesubcommand generates valid JSON template - Template includes helpful placeholder values
- Template includes comments explaining each field (if JSON supports it, or in separate docs)
- Custom output paths are supported
- Default filename is
environment-template.json - Error handling follows tiered help system pattern
- Help text provides clear usage examples
Implementation Notes
- Extend existing CLI subcommand structure from Subissue 3
- Use TemplateManager from Subissue 6 for template generation
- Follow existing patterns for CLI subcommands
- Ensure template content matches environment configuration schema
For detailed specification, see: docs/issues/epic-create-environment-command-subissue-7-template-generation-support.md
Activity
docs: [#34] create GitHub issues for Create Environment Command EPIC
docs: [#41] update issue spec to reflect PR #48 implementation
josecelano commentedon Oct 27, 2025
✅ Issue Documentation Updated
The issue specification has been updated to reflect the implementation completed in PR #48.
Key Changes
Previous specification was outdated - it was written before PR #48 implemented struct-based template generation in the domain layer.
New v2 specification: docs/issues/41-subissue-7-template-generation-support-v2.md
What Changed
EnvironmentCreationConfig::generate_template_file()methodCreateConfigErrorenumWhat's Already Done ✅
src/domain/config/environment_config.rs.help()methodsWhat Needs to Be Done
templatesubcommand to CLI argument parserWhy This Makes Implementation Easier
The hard work (template generation, error handling, validation) is already complete. This issue is now just about exposing that functionality through a CLI subcommand - a straightforward CLI integration task.
For Implementation
@copilot When implementing this:
EnvironmentCreationConfig::generate_template_file(&path).awaitsrc/infrastructure/templates/moduleSee the v2 specification for complete implementation details with code examples.
feat: [#41] add template subcommand for create command
Merge #49: Add template subcommand for create command
chore: remove closed issue documentation files