robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
168 stars 13 forks source link

[ENHANCEMENT] Support for Internal Variables in toml config files #253

Open simonmeggle opened 2 months ago

simonmeggle commented 2 months ago

I want to suggest an enhancement to introduce "internal variables" within configuration files. This feature would allow developers to define variables at the start of the configuration file, which can be reused throughout, simplifying configuration management and updates.

Overview

This proposal introduces the concept of 'internal variables' within configuration files. The suggested feature would allow developers to define reusable variables at the beginning of a configuration file, simplifying the management of configurations that are used across various sections of the file.

Current Situation

Currently, configurations for different environments (such as TEST, DEV, and PROD) need explicit variable definitions for each section or profile, tailored to specific requirements. This can lead to redundancy and complexity in configuration files, especially when the same values are used in multiple places.

Challenges Addressed

In development environments where multiple configurations need to coexist, the lack of reusable variables means that each change requires updates in multiple locations, increasing the risk of errors and inconsistency.

Proposed Enhancement

To enhance efficiency and reduce redundancy, it is proposed to introduce an internal-variables section at the start of configuration files. Variables defined here could be referenced throughout the configuration using a simple notation, which would streamline updates and ensure consistency across various sections of the configuration.

Example of Proposed Feature:

[internal-variables]
VARIABLE_NAME = "value"

[profiles.EXAMPLE]
SETTING = "%%VARIABLE_NAME%%"

In this configuration, %%VARIABLE_NAME%% would represent an internally defined variable. This setup allows for central management of variable values, where changing the value in the internal-variables section automatically updates all references throughout the file.

Benefits

  1. Centralized Configuration Management: Enables single-point updates for variables used in multiple configurations, enhancing consistency.
  2. Simplicity and Clarity: Reduces the complexity of the configuration files, making them more manageable and less prone to errors.
  3. Increased Flexibility: Facilitates easier adjustments and testing in environments where configurations frequently change.
d-biehl commented 2 months ago

this seems to be a good idea ;-)