Skip to content
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

Allow property action attributes to not fail (continue to next action) if unresolved. #147

Closed
end2endzone opened this issue Jan 14, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@end2endzone
Copy link
Owner

Is your feature request related to a problem? Please describe.
<property> action attributes such as file, registrykey or searchpath will fail if not resolved. For example the following will fail and the following action will not executed:

  • Using file="foobar.txt" when the file foobar.txt does not exists.
  • Using registry="HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip\Path64" when 7-zip is not installed.
  • Using searchpath="python.exe" when Python is not installed.

It would be helpful to be able to prevent failing and keep executing the next action. Without this feature, <property> action must be ordered from the least expected to fail to the most expected to fail action. This creates unnecessary complexity. This is mostly required when setting Default properties.

Describe the solution you'd like
A fail attribute should be added to the <property> element. The attribute's value should evaluate to true or false. See istrue attribute or isfalse attribute logic for details. The default value shall be true to match legacy logic.
For example:

<default>
  <!-- Do not skip setting property `workspace.dir` if Python or 7-zip is not installed on the system -->
  <property fail="no" name="python.exe.path" searchpath="python.exe" />
  <property fail="no" name="sevenzip.dir" registry="HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip\Path64" />
  <property name="workspace.dir" value="C:\my_workspace" />
</default>

When a <property> action fails to resolve to a value (file not found, registry key not found, filename not in PATH) and fail attribute evaluates to true, an error should be generated in the logs and the execution of the next action should be cancelled.

If however fail attribute evaluates to false, a warning should be logged and the execution of the next action shall continue.

Describe alternatives you've considered
N/A

Additional context
N/A

@end2endzone end2endzone added the enhancement New feature or request label Jan 14, 2024
@end2endzone end2endzone added this to the 0.9.0 milestone Jan 14, 2024
@end2endzone end2endzone changed the title Allow property elements to not fail (continue to next action) if unresolved. Allow property action attributes to not fail (continue to next action) if unresolved. Jan 15, 2024
end2endzone added a commit that referenced this issue Jan 15, 2024
Moved most of the logic of PropertyAction::Execute() to independant functions: `GetValueFromExprtk()`, `GetValueFromFile()`, `GetValueFromRegistryKey()` and `GetValueFromSearchPath()`.
This increases cohesion, reduces complexity. It also uses the same design as Validator::Validate() function.
end2endzone added a commit that referenced this issue Jan 15, 2024
#147.

* Fixed issue #147: Allow property action attributes to not fail (continue to next action) if unresolved.
end2endzone added a commit that referenced this issue Jan 15, 2024
* feature-issue147:
  * Updated documentation for `fail` attribute of the <property> element. #147. * Fixed issue #147: Allow property action attributes to not fail (continue to next action) if unresolved.
  Implemented `fail` attribute of the <property> element. #147. Moved most of the logic of PropertyAction::Execute() to independant functions: `GetValueFromExprtk()`, `GetValueFromFile()`, `GetValueFromRegistryKey()` and `GetValueFromSearchPath()`. This increases cohesion, reduces complexity. It also uses the same design as Validator::Validate() function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant