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

Feature: implement a cargo component add command. #5

Closed
peterhuene opened this issue Apr 18, 2022 · 4 comments
Closed

Feature: implement a cargo component add command. #5

peterhuene opened this issue Apr 18, 2022 · 4 comments
Assignees

Comments

@peterhuene
Copy link
Member

Now that cargo-add has been merged into cargo proper, we should definitely have an analogous command for cargo-component.

Something as simple as cargo component add --version 0.1.0 foo.wit editing Cargo.toml to include:

foo = { version = "0.1.0", path = "foo.wit" }

And cargo component add --version 0.1.0 --export foo.wit adds:

foo = { version = "0.1.0", path = "foo.wit", export = true }
@peterhuene
Copy link
Member Author

I imagine in the future this command would be updated to add references to components from a registry:

cargo component add foo

@saulecabrera
Copy link
Member

saulecabrera commented Apr 20, 2022

What do you think about modifying the command slightly to take a --path argument to signal that it should reference a local wit definition? Something like:

cargo component add --path /path/to/foo.wit --version 0.1.0 foo

Omitting the --path argument (or perhaps introducing a different argument) could signal referencing a component from a registry in the future.

The advantage that I see is that this approach is that it is standard with the definition of the component.dependencies entries in the Cargo.toml, in which the name of the wit files don't share a 1-1 relationship with the name of the component.

@peterhuene
Copy link
Member Author

Indeed, I think what you propose makes the most sense and for now we can treat --path as required.

@peterhuene
Copy link
Member Author

Implemented in #18.

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

2 participants