Skip to content

Commit

Permalink
refactor(toolchain): extract DistributableToolchain::components()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Jan 15, 2024
1 parent 935a5f7 commit f2ecc75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,7 @@ pub(crate) fn list_components(

pub(crate) fn list_installed_components(distributable: DistributableToolchain<'_>) -> Result<()> {
let t = process().stdout();
let manifestation = distributable.get_manifestation()?;
let config = manifestation.read_config()?.unwrap_or_default();
let manifest = distributable.get_manifest()?;
let components = manifest.query_components(distributable.desc(), &config)?;

for component in components {
for component in distributable.components()? {
if component.installed {
writeln!(t.lock(), "{}", component.name)?;
}
Expand Down
8 changes: 8 additions & 0 deletions src/toolchain/distributable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ impl<'a> DistributableToolchain<'a> {
Ok(())
}

pub(crate) fn components(&self) -> anyhow::Result<Vec<crate::dist::manifest::ComponentStatus>> {
let manifestation = self.get_manifestation()?;
let config = manifestation.read_config()?.unwrap_or_default();
let manifest = self.get_manifest()?;
let components = manifest.query_components(self.desc(), &config)?;
Ok(components)
}

/// Are all the components installed in this distribution
pub(crate) fn components_exist(
&self,
Expand Down

0 comments on commit f2ecc75

Please sign in to comment.