fix: Improve CLI flag validation for single-word flags
Fix issue with kebab-case validator incorrectly flagging single-word flags like --prompt. Refactor detectCamelCaseFlags to properly handle all single-word flags. Update tests to verify correct behavior with single-word and camelCase flags. Add support for alternative flag formats in init command (e.g., -my_name). This fixes a bug where users couldn't use the --prompt flag directly and had to use -p instead.
This commit is contained in:
42
tasks/task_031.txt
Normal file
42
tasks/task_031.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
# Task ID: 31
|
||||
# Title: Add Config Flag Support to task-master init Command
|
||||
# Status: pending
|
||||
# Dependencies: None
|
||||
# Priority: low
|
||||
# Description: Enhance the 'task-master init' command to accept configuration flags that allow users to bypass the interactive CLI questions and directly provide configuration values.
|
||||
# Details:
|
||||
Currently, the 'task-master init' command prompts users with a series of questions to set up the configuration. This task involves modifying the init command to accept command-line flags that can pre-populate these configuration values, allowing for a non-interactive setup process.
|
||||
|
||||
Implementation steps:
|
||||
1. Identify all configuration options that are currently collected through CLI prompts during initialization
|
||||
2. Create corresponding command-line flags for each configuration option (e.g., --project-name, --ai-provider, etc.)
|
||||
3. Modify the init command handler to check for these flags before starting the interactive prompts
|
||||
4. If a flag is provided, skip the corresponding prompt and use the provided value instead
|
||||
5. If all required configuration values are provided via flags, skip the interactive process entirely
|
||||
6. Update the command's help text to document all available flags and their usage
|
||||
7. Ensure backward compatibility so the command still works with the interactive approach when no flags are provided
|
||||
8. Consider adding a --non-interactive flag that will fail if any required configuration is missing rather than prompting for it (useful for scripts and CI/CD)
|
||||
|
||||
The implementation should follow the existing command structure and use the same configuration file format. Make sure to validate flag values with the same validation logic used for interactive inputs.
|
||||
|
||||
# Test Strategy:
|
||||
Testing should verify both the interactive and non-interactive paths work correctly:
|
||||
|
||||
1. Unit tests:
|
||||
- Test each flag individually to ensure it correctly overrides the corresponding prompt
|
||||
- Test combinations of flags to ensure they work together properly
|
||||
- Test validation of flag values to ensure invalid values are rejected
|
||||
- Test the --non-interactive flag to ensure it fails when required values are missing
|
||||
|
||||
2. Integration tests:
|
||||
- Test a complete initialization with all flags provided
|
||||
- Test partial initialization with some flags and some interactive prompts
|
||||
- Test initialization with no flags (fully interactive)
|
||||
|
||||
3. Manual testing scenarios:
|
||||
- Run 'task-master init --project-name="Test Project" --ai-provider="openai"' and verify it skips those prompts
|
||||
- Run 'task-master init --help' and verify all flags are documented
|
||||
- Run 'task-master init --non-interactive' without required flags and verify it fails with a helpful error message
|
||||
- Run a complete non-interactive initialization and verify the resulting configuration file matches expectations
|
||||
|
||||
Ensure the command's documentation is updated to reflect the new functionality, and verify that the help text accurately describes all available options.
|
||||
Reference in New Issue
Block a user