Skip to content

Commit

Permalink
Merge pull request #5 from mikkelhegn/main
Browse files Browse the repository at this point in the history
Exit early if no interfaces are exported from the component
  • Loading branch information
karthik2804 authored Oct 31, 2024
2 parents 5afb01a + 07522b2 commit badd527
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/commands/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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()),
Expand Down Expand Up @@ -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<String, Vec<String>> = HashMap::new();
let mut selected_interfaces: Vec<String> = Vec::new();

Expand Down

0 comments on commit badd527

Please sign in to comment.