Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Package::from_wit convenience #92

Open
rylev opened this issue Apr 19, 2024 · 0 comments
Open

Add Package::from_wit convenience #92

rylev opened this issue Apr 19, 2024 · 0 comments

Comments

@rylev
Copy link
Collaborator

rylev commented Apr 19, 2024

It would be nice to have some sort of convenience for declaring a wac_types::Package from wit files.

Essentially replacing this code:

let mut resolve = wit_parser::Resolve::new();
let pkg = if path.is_dir()
   let (pkg, _) = resolve.push_dir(path)?;
   pkg
} else {
  let unresolved = wit_parser::UnresolvedPackage::parse_file(&path)?;
  resolve.push(unresolved)?
};
let bytes = wit_component::encode(Some(true), &resolve, pkg)?;
wac_graph::types::Package::from_bytes(
  name,
  None,
  bytes.to_owned(),
  types,
)

Of course, this ties wac_types to the convention from wit_parser, but the wac_cli already does this, so I don't see why it would be inappropriate in wac_types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant