You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a generic which method to allow code to find the location of executable programs and scripts that are in the PATH.
The location that seems to make the most sense is the Processes and ProcessHelper classes, since these contain methods related to processes. The which method is related to processes since you can find a program, shell script, etc. and then also use Processes to launch it.
varvaultPath = Processes.which("ansible-vault");
// do something with it...
In ProcessHelper the which method is an instance method to make it easy to mock if needed in test code.
In Processes the which method should be a static method like everything else in that (pure utility) class. In addition, we might consider returning a "Result" instead of Optional to provide more information (i.e. like an "Either" having a value or an error/exception). However, kiwi doesn't have an Either and I'm not sure we want to add one or depend on another library such as the either library at the present time. Java needs to add one, but that's probably not happening any time soon, or ever.
Add a generic
which
method to allow code to find the location of executable programs and scripts that are in thePATH
.The location that seems to make the most sense is the
Processes
andProcessHelper
classes, since these contain methods related to processes. Thewhich
method is related to processes since you can find a program, shell script, etc. and then also useProcesses
to launch it.The method signatures can be:
Usage example:
In
ProcessHelper
thewhich
method is an instance method to make it easy to mock if needed in test code.In
Processes
thewhich
method should be a static method like everything else in that (pure utility) class. In addition, we might consider returning a "Result" instead ofOptional
to provide more information (i.e. like an "Either" having a value or an error/exception). However, kiwi doesn't have anEither
and I'm not sure we want to add one or depend on another library such as the either library at the present time. Java needs to add one, but that's probably not happening any time soon, or ever.This originated from discussion #944
The text was updated successfully, but these errors were encountered: