Closed thekid closed 3 years ago
This pull request adds the ability to resolve multiple commands, and control whether an exception should be raised or NULL returned instead.
use lang\Process; // Resolve either docker or podman, raise an exception if neither is found $containers= Process::resolve(['docker', 'podman']); // Optionally resolve commands by passing true $download= match (true) { !is_null($cmd= Process::resolve('curl', true)) => fn($url, $target) => $cmd.' "-#" -L "'.$url.'" -o "'.$target.'"', !is_null($cmd= Process::resolve('wget', true)) => fn($url, $target) => $cmd.' -nv "'.$url.'" -O "'.$target.'"', default => throw new IllegalArgumentException('Either curl or wget is required'), };
Superseded by #281
This pull request adds the ability to resolve multiple commands, and control whether an exception should be raised or NULL returned instead.