pub struct CliTool { /* private fields */ }Expand description
One app’s bundled command-line tool and where to install it.
Implementations§
Source§impl CliTool
impl CliTool
Sourcepub fn new(name: &str, helper: impl Into<PathBuf>) -> Result<Self, CliToolError>
pub fn new(name: &str, helper: impl Into<PathBuf>) -> Result<Self, CliToolError>
The tool name at helper, installed into SYSTEM_BIN_DIR with ~/.local/bin as the
fallback and the OS’s admin prompt; ENV_BIN_DIR / ENV_FALLBACK_DIR override the
folders (and turn the prompt off).
Sourcepub fn for_current_app(name: &str) -> Result<Self, CliToolError>
pub fn for_current_app(name: &str) -> Result<Self, CliToolError>
CliTool::new with the running app’s bundled_helper.
Sourcepub fn bin_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn bin_dir(self, dir: impl Into<PathBuf>) -> Self
Install into dir instead of the system folder.
Sourcepub fn fallback_dir(self, dir: Option<PathBuf>) -> Self
pub fn fallback_dir(self, dir: Option<PathBuf>) -> Self
Fall back to dir (None: no fallback, a declined prompt is an error).
pub fn elevation(self, elevation: Elevation) -> Self
Sourcepub fn prompt(self, text: impl Into<String>) -> Self
pub fn prompt(self, text: impl Into<String>) -> Self
The text shown in the administrator prompt.
pub fn name(&self) -> &str
pub fn helper(&self) -> &Path
Sourcepub fn helper_present(&self) -> bool
pub fn helper_present(&self) -> bool
The tool exists in the app.
Sourcepub fn status(&self) -> Status
pub fn status(&self) -> Status
Where the tool is installed: the system link, or the fallback one when the system folder holds nothing and the fallback does.
Sourcepub fn install(&self, replace: bool) -> Result<Installed, CliToolError>
pub fn install(&self, replace: bool) -> Result<Installed, CliToolError>
Link the tool into the system folder (asking for admin rights when needed), or into the
fallback when that is declined. Repairs a stale link. replace allows replacing a file or
a link that isn’t ours (never a folder).
Sourcepub fn repair(&self) -> Result<Option<Installed>, CliToolError>
pub fn repair(&self) -> Result<Option<Installed>, CliToolError>
Install only when the link is stale (the app moved); otherwise report the status.
Sourcepub fn uninstall(&self) -> Result<Removed, CliToolError>
pub fn uninstall(&self) -> Result<Removed, CliToolError>
Remove this app’s links (and stale ones) from both folders. Anything else stays.