From 8231e9a5d9c47c80002ba8ac4dd7e5af912c5945 Mon Sep 17 00:00:00 2001 From: rami3l Date: Mon, 15 Jan 2024 14:11:57 +0800 Subject: [PATCH] refactor(toolchain): extract `DistributableToolchain::components()` --- src/cli/common.rs | 7 +------ src/toolchain/distributable.rs | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/cli/common.rs b/src/cli/common.rs index 9a85aca25b..20cbe7d1e1 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -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)?; } diff --git a/src/toolchain/distributable.rs b/src/toolchain/distributable.rs index d5aeadb8dc..8bc77901c2 100644 --- a/src/toolchain/distributable.rs +++ b/src/toolchain/distributable.rs @@ -115,6 +115,13 @@ impl<'a> DistributableToolchain<'a> { Ok(()) } + pub(crate) fn components(&self) -> anyhow::Result> { + let manifestation = self.get_manifestation()?; + let config = manifestation.read_config()?.unwrap_or_default(); + let manifest = self.get_manifest()?; + manifest.query_components(self.desc(), &config) + } + /// Are all the components installed in this distribution pub(crate) fn components_exist( &self,