The motivation is I wanted my egui app to take come command line arguments, and wanted it to also work on the web.
Normal clap is broken, it doesn't work on the web. There have been some threads on the clap github in the past and at least a few times people on this group ask how to parse url query strings.
There are plenty of examples
Here is a screencast of a basic egui app running on a webpage and parsing the URL as a command line.
Next steps I try to figure out how to do a proper pull request to the clap main repository. @epage
I think it's about as good an solution as any to get this working, but the conventions are different enough I think it's pretty reasonable for clap to consider the web unsupported. For example, sight unseen I would expect --help to translate to ?help and --foo bar to be ?foo=bar, though I can guess as to why that might not work in the context of clap.
Looking over the commits, it seems this mostly changes the default source of argv and the default location to print to. I feel like this is specialized enough that we probably don't want baked in support for this but to use the integration points we offer (e.g. Command::get_matches_from, impl DIsplay for Error, Error::render) to integrate with something like this. If there are remaining points in clap that can cause problems, that would be worth opening an issue for us to explore how we should handle them.
Thank for looking.
I had a feeling you would not be too interested in including my patches. You have said in the past on clap discussion that you haven't used clap on wasm.
But I do feel that a way to clap on the web is not "specialized" The web may account for half of computer program use. (trump style statistic pulled from the air)
I may, if have time, go to the clap repository and bring up some discussion in the Designing Clap for Extensibiliy chat and link to some past issues.
Maybe there is interest in others, maybe not. I was thinking out doing it all outside clap, calling into clap and doing the work outside. But I could not think of a way to do it that would make it easy to use for others. My goal is to make it so users don't need to learn anything new to use it, just use clap like normal and it works on the web.
Clap uses -- to tell if it is option or just an argument. I don't want to change behavior or how to use. Just replace the argument separator with ? and & instead of using spaces. There is a benefit that you don't need to use quotes around stings with spaces.
That's because it was never so easy to get clap powers on the web.
Any way, thanks for the rejection. I needed the motivation to do it outside of clap. So I wrote we_clap
I thought it would be easier to just patch clap, but I think a separate crate is better. Of course I could use some help from a clap pro. I want to change the error/help output to use "?" and "&" instead of spaces.
As I said elsewhere, it wasn't easy to get clap power on the web before.
I think after I submit a patch to official egui_demo_app, using we_clap to read the args, "--profile" for example, and adding args that pass values to the demo. After I write some examples with ratatui and ratzilla that can run on native or web, and take arguments. After the world sees the beauty, it will flourish.