-
-
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
Add method to parse environment variables from custom source #4607
Comments
Ok, so this is not wasm in the browser (where there is no environment) but embedded within a desktop application where the environment needs to be proxied. |
One aspect of that that is weird to me, as an API, is that its updating the envs already stored. I think I'd rather we set the env to use and use that instead. As this is a special use case on top of special use case, I would want to limit the impact of this on others (note that testing would be another use case). You mentioned limiting it to wasm but this has use outside of wasm and I tend to avoid conditional compilation (we already have too much in clap). I have been exploring ideas to make new features cheaper and this would be a good first use of the idea. Buried in that page is a plugin system where a The above does require setting the env source before adding any other args. We could re-evaluate when we read the environment to make this more flexible on when either is called. |
It works mostly like before:
... with the only difference that first all |
The idea was to have one Rust source code that is normally fed with |
FYI I've created #4793 as an issue dedicated to that plugin system idea I mentioned. Our plan is to move |
As mentioned in #5104, another use case is implementing I have to mention that I was surprised that |
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
This is intended to resolve clap-rs#4607, and also my earlier request clap-rs#5104 which was closed in favor of clap-rs#4607 This is obviously not as powerful as the plugin system envisioned here clap-rs#4607 (comment) but it is simple and might be a useful stopgap until such time as the plugin system exists. Fixes clap-rs#4607
Please complete the following tasks
Clap Version
4.0.32
Describe your use case
Rust code might run as a standalone application as well as a WebAssembly module in the browser or in any other WebAssembly runtime.
This comes with the advantage that WebAssembly modules and standalone applications share the same code and benefit from the stability and safety of Rust.
Within WebAssembly, in most cases the execution environment cannot access process variables such as
argv
and environment variables - which are very often used for configuration - , hence they somehow need to get passed into the WebAssembly module. Fortunately, this shim functionaliy is only necessary when compiling to WebAssembly.Describe the solution you'd like
Since
std::env::vars()
orstd::env::vars_os()
are not available, add a method that allows passing environment variables from a custom source intoclap
.Example
Alternatives, if applicable
No response
Additional Context
See #4605 for sample implementation.
This functionality could be hidden by a
wasm
feature flag.The text was updated successfully, but these errors were encountered: