end2endzone / ShellAnything

ShellAnything is a C++ open-source software which allow one to easily customize and add new options to *Windows Explorer* context menu. Define specific actions when a user right-click on a file or a directory.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

end2endzone opened this issue · comments

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