-
Couldn't load subscription status.
- Fork 0
Add template subcommand for create command #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This implements the template generation CLI subcommand, allowing users to generate configuration file templates via the CLI. Changes: - Updated CLI command structure to support create subcommands (environment/template) - Added CreateAction enum with Environment and Template variants - Implemented handle_template_generation() handler that calls existing domain method - Added user-friendly success messages with next steps instructions - Updated command routing to handle new subcommand structure - Added comprehensive tests for CLI argument parsing and template generation - Updated existing tests to work with new subcommand structure The implementation is a thin CLI wrapper that delegates to the existing EnvironmentCreationConfig::generate_template_file() method from the domain layer. CLI Usage: - Generate template: torrust-tracker-deployer create template - Custom path: torrust-tracker-deployer create template ./config/my-env.json - Create environment: torrust-tracker-deployer create environment --env-file <file> Co-authored-by: josecelano <[email protected]>
Co-authored-by: josecelano <[email protected]>
|
@copilot linting workflow is failing: |
- Merge identical match arms in error help method - Replace wildcard patterns with explicit variants in test assertions Co-authored-by: josecelano <[email protected]>
... Fixed in commit 48dd8a0. The clippy warnings have been resolved:
All 971 tests pass and clippy runs cleanly with no warnings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 48dd8a0
Implementation Complete: Template Generation CLI Support (Issue #41)
This PR implements the
templatesubcommand for the create command, allowing users to generate configuration file templates via the CLI.Implementation Checklist ✅
createsubcommands (environment/template)CreateActionenum withEnvironmentandTemplatevariantshandle_template_generation()handler that calls domain methodSecurity Summary
No new security vulnerabilities introduced.
This implementation is a thin CLI wrapper that:
EnvironmentCreationConfig::generate_template_file().help()methodstokio::fs::create_dir_all()tokio::fs::write()The security posture is maintained by:
Test Results
CLI Usage Examples
Closes
Original prompt
This section details on the original issue you should resolve
<issue_title>[Subissue 7/7] Template Generation Support (Optional)</issue_title>
<issue_description>Parent Epic: #34 - Implement Create Environment Command
Depends On: #40 - Template System Integration
Status: OPTIONAL ENHANCEMENT
Estimated Time: 1-2 hours
Overview
Implement the
templatesubcommand for the create command, allowing users to generate configuration file templates. This enhances user experience by providing a starting point for configuration creation.Goals
templatesubcommand in the create command structureArchitecture 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
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 templatesubcommand generates valid JSON templateenvironment-template.jsonImplementation Notes
For detailed specification, see: docs/issues/epic-create-environment-command-subissue-7-template-generation-support.md</issue_description>
<agent_instructions>@copilot Please implement this issue using the v2 specification:
📋 Use this spec: docs/issues/41-subissue-7-template-generation-support-v2.md
This is a simple CLI integration task - just add the template subcommand and call the existing domain method. Don't create new template generation logic or infrastructure modules.</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@josecelano ## ✅ Issue Documentation UpdatedThe 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()methods💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.