Skip to content

[Subissue 7/7] Template Generation Support (Optional) #41

@josecelano

Description

@josecelano

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 template subcommand 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 --help

Template 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 template subcommand 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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions