RichoDemus/bevy-console

Integration with `clap`

Closed this issue · 7 comments

Clap is a CLI argument parser for rust. It is clear it contains functionality which could be very useful to this crate. It is entirely possible that a large amount of logic can be outsourced to clap which would be very beneficial.

Clap offers argument formats which are much more flexible than the current parser can handle at the moment.

We might still need a macro on top of the original clap macro to control which options are available to the user (since some features like env variables should likely not be made available)

I would be happy to review and mentor this issue if anyone wants to tackle it.

I've started some experimental work on the 'feature/clap-integration' branch. A dual derive macro setup where the second derive macro implements validity checks and additional necessary traits seems to work well, need to make sure there aren't ways to break this via certain clap features but looking good so far

I am now looking at integrating the coloured output from clap as well, there is one issue: clap-rs/clap#4611. I don't think there is a way to get the styling information from the StyledStr's which is annoying. is std::mem::transmute into a replicating public type a good idea here :P

Drop it from the MVP and keep the initial PR smaller IMO :)

MVP available over at #39 now, reviews would be appreciated as this changes the fundamental way this crate works

Is colored console supported yet? I believe that clap has stabilized its api here: clap-rs/clap#4765

Not yet, but if this is the case then I think we can add that pretty easily, looks like we'll have to parse the ANSI chars and interpret them appropriately ourselves