-
Notifications
You must be signed in to change notification settings - Fork 60
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 argument parsing, add_console_command
and other features
#4
Conversation
First pass on code quality looks good! I'm generally impressed with the features and ergonomics of the design. |
Thanks for the PR and for all the comments, I'll try to take a look this week! |
Made some updates including:
|
I also tried tackling the issue #2 of blocking input when the console is open by clearing the input events, but doing so made the console terminal break too not allowing you to press enter. This issue is a difficult one to solve which I'm not sure is really possible. |
This looks very good, thanks a lot for your effort. I'm very positive to merging this, I just have a few things
|
Thanks for the feedback!
I had a look through but couldn't really see any old code commented out. Perhaps you just saw my doc comment examples and mistook it for old code I commented out? The only commented code I could find, I've removed in this commit: tqwewe@5458546
I agree that it's a little magical, but I think that's just part of the power of Rust macros. I don't really feel that it's overly magical to confuse the user though, it's just a feature of macros imo. If it was an attribute, then what if you also wanted doc comments? It might be a little frustrating to have to write your info twice. /// Prints given arguments to the console
#[derive(ConsoleCommand)]
#[console_command(name = "log")]
#[console_command(help = "Prints given arguments to the console")]
pub struct LogCommand {
/// Message to print
#[console_command(help = "Message to print")]
pub msg: String,
/// Number of times to print message
#[console_command(help = "Number of times to print message")]
pub num: Option<i64>,
} I feel that this just adds too much boilerplate when the help would almost always be the same as the doc comment right? And you also have the annoying thing of the docs going out of sync with the help attribute, whereas having it all as a doc comment kind of kills two birds with one stone without many disadvantages.
If that's true then it is indeed a down side. /// Here is a doc comment for my Rust code
#[console_command(help = "Message to print")]
msg: String,
/// Number of times to print message
num: Option<i64>, I'm curious to hear if @alice-i-cecile has any thoughts on this? |
Oh yeah, and |
I've just fixed the doc tests, so it should all be passing now |
This PR is a breaking change and adds a lot of things including:
app.add_console_command
ConsoleCommand
system parameterhelp
,clear
andexit
console commandsThere's a lot to go through, the best place to start would be to clone the fork and run the examples.
Basic example of defining and handling a console command:
This code snippet will register the command when the user enters
help
andhelp log
(using doc comments), and will only execute if the arguments are parsed successfully into the correct types.