From 07522b2db037b0c0c8cd8930e3efe81518f4a72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikkel=20M=C3=B8rk=20Hegnh=C3=B8j?= Date: Thu, 31 Oct 2024 15:32:14 +0100 Subject: [PATCH] Exit early if no interfaces are exported from the component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mikkel Mørk Hegnhøj --- src/commands/add.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/commands/add.rs b/src/commands/add.rs index 89200fc..a5c0b44 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -68,7 +68,7 @@ impl ComponentSource { if let Ok((name, version)) = package_name_ver(source) { if version.is_none() { - bail!("Version needs to specified for regitry sources.") + bail!("Version needs to specified for registry sources.") } return Ok(Self::Registry(RegistryAddCommand { package: name, @@ -96,6 +96,8 @@ impl AddCommand { let (mut resolve, main) = parse_component_bytes(component)?; + let selected_interfaces = self.select_interfaces(&mut resolve, main)?; + let mut manifest = manifest_from_file(get_spin_manifest_path()?)?; let component_ids = get_component_ids(&manifest); let selected_component_index = select_prompt( @@ -105,8 +107,6 @@ impl AddCommand { )?; let selected_component = &component_ids[selected_component_index]; - let selected_interfaces = self.select_interfaces(&mut resolve, main)?; - resolve.importize( resolve.select_world(main, None)?, Some("dependency-world".to_string()), @@ -143,6 +143,10 @@ impl AddCommand { let world_id = resolve.select_world(main, None)?; let exported_interfaces = get_exported_interfaces(resolve, world_id); + if exported_interfaces.is_empty() { + bail!("No exported interfaces found in the component") + }; + let mut package_interface_map: HashMap> = HashMap::new(); let mut selected_interfaces: Vec = Vec::new();