-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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(cli): dioxus-cli as lib #3362
Conversation
Thanks for running the checks. I will fix them asap. |
Thanks! Also - do you mind adding a I'm okay with opening up the CLI as a library but that means the CLI needs to follow semver. We should try to keep our public API minimal in that case. This means marking things as no_exhaustive where possible and not making too many things public. |
Going to close this since it's been open for a while... Also, having a little while to think about it, I'm not 100% sure we want to open up the CLI as a semver API. I'd be happy to accept a PR that exposes more of our types for Process/Command consumption, but I generally don't think people would even want to develop against the CLI. It's very heavy to develop against and does many weird things like overriding loggers, ctrl-c, sigkill, etc. If you want to use the CLI from a script then I'd recommend using the types crates we provide to parse the output with JSON mode enabled. |
I had to put the web-component effort on hold. But I might come back to this as this is something that would make it easier for me to release a cli that depends on dioxus-cli |
For sure - we could expose our CLI's arguments as an independent library instead of the entire CLI. We do that with the return types in the |
But doesn't that mean that I need to ask for my cli user to download and install dioxus-cli? |
You could download it for them with Tools like https://github.com/dustinblackman/cargo-run-bin can automate downloading the right dx version for you, allowing you to get a handle to the program and execute it. |
@jkelleyrtp thanks a lot for the suggestions. I didn't know these crates :) |
Problem
While it is possible to wrap dx using std::process::Command, a more flexible and programmable approach would be to reuse dioxus-cli as a library. Publishing dioxus-cli as a library would greatly enhance its usability.
Solution
This PR exposes
dioxus-cli
as a library, making it possible to reusedx
instead of redirecting cli commands to it.A good example is how
bolt-cli
usesanchor-cli
as a library.https://github.com/magicblock-labs/bolt/blob/main/crates/bolt-cli/src/lib.rs