Closed mendelt closed 5 years ago
hi i'm trying to override a help function but the fields are private
This feature hasn't been implemented yet so there is no way to have dynamically generated help at the moment. Static help text for a command does work, that might solve your problem. If you can post some code with an example of what you're trying to do maybe I can give you some more specific help.
if you can fix it, it would be great 👍
Thanks, I hadn't meant for the help command to be overridden like this, but I can imagine that it can be useful. I'll have a look at making this possible. The help function is a bit of a placeholder right now and it will change in the future anyway. I'm also curious why you are trying to replace the built in help. What features is it missing? Maybe I can make it fit your use-case?
i just want to create my own help structure and for making it possible i need to achieve command name and description from struct that is currently private.
No problem. I'm just finishing up a feature for version 0.3.8. I'll prioritize this for 0.3.9 then.
Do be aware that I'll probably change the way commands are parsed for 0.4, this might cause internal structs like the ones you want to access to change.
Also let me know if you have any more feedback about cmdr. I do see that it's being used a bit but you're the only user who has contacted me so far.
if you can add others keys feature like tab and autocompletion it would be great.
i find this crate after 2h of research about cli in web (and if i have to say, it work perfectly), maybe it's for this reason that is not so used or viewed.
thanks for your time 👍
Yeah, I havent been very good at promoting this crate. I think I first wanted it to be a bit more finished. Autocompletion is certainly still coming. As well as better argument parsing and a better help system. I just finished switching to other scopes today, which was a feature I was struggeling with a bit. So hopefully those other features will be easier. :-)
Thanks for the feedback! I'll let you know when I have something you can use.
perfect 👍
I got some fixes for you checked in to master. You should be able to get to them by adding;
[dependencies]
cmdr = { git = "https://github.com/mendelt/cmdr", branch = "master" }
to your Cargo.toml. I made some changes to the help function so be sure to look at the new source code. Let me know if this helps you. Then I'll release it as 0.3.9.
I pushed release 0.3.9. As the original ticket (dynamic help) is not something that I will implement before 1.0 I'll close this ticket.
Allow dynamic help instead of using doc strings or a help parameter on the cmd attribute as help text. This can be done by letting the library user specify a method to call that provides the help text and then calling it the moment help is retrieved.