Skip to content

Commit badd527

Browse files
authored
Merge pull request #5 from mikkelhegn/main
Exit early if no interfaces are exported from the component
2 parents 5afb01a + 07522b2 commit badd527

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/commands/add.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl ComponentSource {
6868

6969
if let Ok((name, version)) = package_name_ver(source) {
7070
if version.is_none() {
71-
bail!("Version needs to specified for regitry sources.")
71+
bail!("Version needs to specified for registry sources.")
7272
}
7373
return Ok(Self::Registry(RegistryAddCommand {
7474
package: name,
@@ -96,6 +96,8 @@ impl AddCommand {
9696

9797
let (mut resolve, main) = parse_component_bytes(component)?;
9898

99+
let selected_interfaces = self.select_interfaces(&mut resolve, main)?;
100+
99101
let mut manifest = manifest_from_file(get_spin_manifest_path()?)?;
100102
let component_ids = get_component_ids(&manifest);
101103
let selected_component_index = select_prompt(
@@ -105,8 +107,6 @@ impl AddCommand {
105107
)?;
106108
let selected_component = &component_ids[selected_component_index];
107109

108-
let selected_interfaces = self.select_interfaces(&mut resolve, main)?;
109-
110110
resolve.importize(
111111
resolve.select_world(main, None)?,
112112
Some("dependency-world".to_string()),
@@ -143,6 +143,10 @@ impl AddCommand {
143143
let world_id = resolve.select_world(main, None)?;
144144
let exported_interfaces = get_exported_interfaces(resolve, world_id);
145145

146+
if exported_interfaces.is_empty() {
147+
bail!("No exported interfaces found in the component")
148+
};
149+
146150
let mut package_interface_map: HashMap<String, Vec<String>> = HashMap::new();
147151
let mut selected_interfaces: Vec<String> = Vec::new();
148152

0 commit comments

Comments
 (0)