Skip to content

Commit f2ecc75

Browse files
committed
refactor(toolchain): extract DistributableToolchain::components()
1 parent 935a5f7 commit f2ecc75

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/cli/common.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,7 @@ pub(crate) fn list_components(
448448

449449
pub(crate) fn list_installed_components(distributable: DistributableToolchain<'_>) -> Result<()> {
450450
let t = process().stdout();
451-
let manifestation = distributable.get_manifestation()?;
452-
let config = manifestation.read_config()?.unwrap_or_default();
453-
let manifest = distributable.get_manifest()?;
454-
let components = manifest.query_components(distributable.desc(), &config)?;
455-
456-
for component in components {
451+
for component in distributable.components()? {
457452
if component.installed {
458453
writeln!(t.lock(), "{}", component.name)?;
459454
}

src/toolchain/distributable.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ impl<'a> DistributableToolchain<'a> {
115115
Ok(())
116116
}
117117

118+
pub(crate) fn components(&self) -> anyhow::Result<Vec<crate::dist::manifest::ComponentStatus>> {
119+
let manifestation = self.get_manifestation()?;
120+
let config = manifestation.read_config()?.unwrap_or_default();
121+
let manifest = self.get_manifest()?;
122+
let components = manifest.query_components(self.desc(), &config)?;
123+
Ok(components)
124+
}
125+
118126
/// Are all the components installed in this distribution
119127
pub(crate) fn components_exist(
120128
&self,

0 commit comments

Comments
 (0)