use super::super::Client;
use super::Manifest;
use crate::filesystem::install::{
ExtraAsset, InstallKind, InstallManifest, platform_cli_zip,
validate_install_inputs,
};
impl Client {
pub async fn install_tool(
&self,
owner: &str,
repository: &str,
commit_sha: Option<&str>,
headers: Option<&indexmap::IndexMap<String, String>>,
upgrade: bool,
) -> Result<bool, super::super::Error> {
self.install_from_github_at::<Manifest>(
"https://raw.githubusercontent.com",
"https://github.com",
owner,
repository,
commit_sha,
headers,
upgrade,
)
.await
}
pub async fn fetch_tool_manifest(
&self,
owner: &str,
repository: &str,
commit_sha: Option<&str>,
headers: Option<&indexmap::IndexMap<String, String>>,
) -> Result<Manifest, super::super::Error> {
self.fetch_manifest_at::<Manifest>(
"https://raw.githubusercontent.com",
owner,
repository,
commit_sha,
headers,
)
.await
}
pub async fn install_tool_from_manifest(
&self,
owner: &str,
repository: &str,
manifest: &Manifest,
headers: Option<&indexmap::IndexMap<String, String>>,
upgrade: bool,
) -> Result<bool, super::super::Error> {
validate_install_inputs(InstallKind::Tool, owner, repository, None)?;
self.install_parsed_at::<Manifest>(
"https://github.com",
owner,
repository,
manifest,
headers,
upgrade,
)
.await
}
#[cfg(test)]
pub(super) async fn install_tool_at(
&self,
raw_base: &str,
releases_base: &str,
owner: &str,
repository: &str,
commit_sha: Option<&str>,
headers: Option<&indexmap::IndexMap<String, String>>,
upgrade: bool,
) -> Result<bool, super::super::Error> {
self.install_from_github_at::<Manifest>(
raw_base,
releases_base,
owner,
repository,
commit_sha,
headers,
upgrade,
)
.await
}
#[cfg(test)]
pub(super) async fn fetch_tool_manifest_at(
&self,
raw_base: &str,
owner: &str,
repository: &str,
commit_sha: Option<&str>,
headers: Option<&indexmap::IndexMap<String, String>>,
) -> Result<Manifest, super::super::Error> {
self.fetch_manifest_at::<Manifest>(
raw_base, owner, repository, commit_sha, headers,
)
.await
}
}
impl InstallManifest for Manifest {
const KIND: InstallKind = InstallKind::Tool;
fn validate_manifest(&self) -> Result<(), &'static str> {
self.validate()
}
fn version(&self) -> &str {
&self.version
}
fn cli_zip_for_platform(&self) -> Option<&str> {
platform_cli_zip(&self.cli_zip)
}
fn extra_assets(&self) -> Vec<ExtraAsset> {
Vec::new()
}
}