Add new line if not present in the clients.yml file #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add newline before appending to config/clients.ymlThis change ensures that a newline is added before appending new content to the config/clients.yml file. It addresses the following scenarios:1. If the file already ends with a newline, no additional newline is added.2. If the file doesn't end with a newline, a newline is inserted before the new content.This modification improves the reliability of the configuration file generation process by preventing potential formatting issues or unintended merging of content.EDITI added also a check for existing configuration in the clients.yml file based on the client_name and client_id to avoid duplicatesEDIT 2
After careful consideration, I've decided to refactor and rewrite a significant portion of the code while maintaining the core logic. This refactoring was necessary to properly handle several edge cases that were not initially accounted for in the original implementation.
Unfortunately, due to the new manipulations performed by the code, I had to introduce a dependency:
The code checks for the existence of a newline at the end of the file, but now in addition to the newline check, the code verifies if a client_id or client_name already exists in the file. If found, the existing entry is modified with the new data instead of adding a duplicate entry.
This enhancement allows for more robust handling of clients, preventing duplicates and ensuring that existing entries are properly updated when new information is available.