khal
khal copied to clipboard
Fix 1341
Improved Error Handling for the khal new -i Command
Identified Issue
When creating an event interactively with khal new -i, an error in one field (e.g., datetime range) forces the user to restart the entire input process, even if other fields are correct. This makes the user experience frustrating and inefficient.
Proposed Solution
This fix improves the new_interactive function by:
- Handling errors iteratively:
- When an invalid input is detected, the user receives a clear error message and can correct only the problematic field.
- Allowing cancellation:
- If the user enters an empty value, the process is canceled without restarting the application.
- Simplifying the user experience:
- Valid data is retained, and only the incorrect fields are re-entered.
Changes Made
- Added a
while Trueloop to manage field validation one by one. - Error handling with a
try-exceptblock to capture and display error messages. - The user can cancel event creation by entering an empty field.
Benefits
- Enhances the user experience during interactive input.
- Reduces frustration caused by repeated errors.
- Provides a flexible and intuitive way to correct invalid inputs.
Testing Instructions
- Run the
khal new -icommand. - Provide valid fields and one invalid field (e.g.,
datetime range: 3d). - Verify that:
- An error message is shown for the invalid field.
- The user can correct only that field without losing valid data.
- Event creation continues once the input is corrected.