Extend ProcessContext with method to set executable and get feedback if available #900
Labels
core
FileAccess, ProcessUtil, IdeContext, etc.
enhancement
New feature or request
process
executing external programs (ProcessContext)
In PR #890 we had the situation that we want to execute a command via
ProcessContext
but only if that binary executable is actually available.Instead of implementing such features inside one or multiple commandlets, it should belong to
ProcessContext
.The idea is to add the following method to
ProcessContext
:It should do the same as
executable(Path executable)
but additionally, it should check if that executable can really be executed.For the implementation this code should be moved to a private method (except for the log message):
IDEasy/cli/src/main/java/com/devonfw/tools/ide/process/ProcessContextImpl.java
Lines 144 to 150 in 83acd3a
Then this method can be reused by the new
setAndCheckExecutable
method.Only this way, we will also reuse the logic that is later performed to run the command (e.g. adding potential
.bat
or.exe
or.msi
extensions and more) without replicating such logic.ATTENTION: We have some special situations where we create the
ProcessContext
early on and set the executable first and then other things happen (in this case installation of dependencies) and later when therun
method is called, the PATH is updated and the executable can be fully resolved. Therefore the default behaviour of the existingexecutable(Path executable)
method shall not change. Only the new method should do the additional features on top.The text was updated successfully, but these errors were encountered: