Class BitwardenCLIManager
This class handles OS detection, on-demand downloading from the official Bitwarden site, extraction of the executable, and provides a reliable, cached path for other components to use. It ensures the CLI is always available when needed, attempting to download it if it's missing.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Forces a download of the latest Bitwarden CLI, overwriting any existing version.Gets the absolute path to the managed Bitwarden CLI executable.static BitwardenCLIManager
Provides global access to the single instance of this manager.boolean
Ensures the Bitwarden CLI executable is present, downloading it if it does not exist.
-
Method Details
-
getInstance
Provides global access to the single instance of this manager.- Returns:
- The singleton instance of
BitwardenCLIManager
.
-
downloadLatestExecutable
public boolean downloadLatestExecutable()Forces a download of the latest Bitwarden CLI, overwriting any existing version.This method performs a blocking, network-intensive operation performed in a thread-safe manner.
- Returns:
true
on success,false
on failure.
-
provisionExecutable
public boolean provisionExecutable()Ensures the Bitwarden CLI executable is present, downloading it if it does not exist.This is the primary method for automatic, on-demand setup. It first checks if the executable exists and only performs the expensive download operation if necessary.
- Returns:
true
if the executable is present or was successfully downloaded, otherwisefalse
.
-
getExecutablePath
Gets the absolute path to the managed Bitwarden CLI executable.This is the main entry point for getting the path to the CLI. It uses an in-memory cache for performance and is self-healing: if the executable is missing for any reason, it will automatically attempt to provision it on-demand.
- Returns:
- The full path to the
bw
executable. - Throws:
IllegalStateException
- if the executable is not found and cannot be downloaded.
-