Great tutorial, One minor thing it's that you should specify that at the toml file you need to specify the derive feature to be able to use it: [dependencies] clap = { version = "3.2.8", features = ["derive"] }
@@codetothemoon Should honestly have showed the entire toml. And I can't figure out what is the difference between the macros "clap" (which you used) and "command" (which the docs suggest using)
What perfect timing. I've been working on a CLI application and basing my argument parsing off one of the projects in the rust book. This looks much nicer to work with, even if I don't need nested arguments!
Excellent - thank you! I couldn't for the life of me figure out how to implement subcommands using the derive framework, and the builder method (the ony example I could find) produces code I find dense and hard to read. Perfect.
I have a question: why create `struct UserCommand`? why not just create an make UserCommand as an enum. That extra stuct then enum step seems unnecessary. Please let me know your thoughts
This was an amazing video, short sweet and to the point. Very informative as well. I would say for future reference, you should probably show the set up of the project, even if it's brief. For example, someone really new to rust might not know that you actually have to add "features = ["derive"]" to their cargo.toml to work correctly. Other than that, great video!
Thxs for this explanation, it clarified me a lot how to define a CLI in rust. I would like to know how we can have bi-directional communication with the rust app and the command line. Could you please do an example of stdin / stdout with rust?
How do you allow for empty values? I want to use a single letter flag set to true when present and false when absent, but also allow for -z true and -z false
Thanks! By app creation do you mean the builder API? If so my understanding is that it's mostly a personal preference thing, though it appears they have very slight differences in capability docs.rs/clap/latest/clap/#selecting-an-api
Any way to make multiple names for the same command, like a semantics thing? say i wanted to create a file and wanted to accept if the command was either 'create' or 'touch'. maybe not important but would like to do it for fun or personal preference..
Hi, thanks for this content. Really really helpful for me. I've been following your implementation of the Rustflix project and I'd like to serialize to JSON the values of `CreateView` or `UpdateVideo` structs (just to mention an example). I have tried several ways but have had no luck. Any hint? Thanks in advance :)
the struct returned by RustflixArgs::parse() should be the struct you applied #[derive(Parser)] to, so you can just pull the values from there! I definitely glossed over this a bit too quickly at the end of the video.
The tutorial is great and helpful. But this American habit /accent to raise the voice at the end of a sentence to make it sound like a question is annoying. This sounds so confusing for a non-english speaker. You have to listen twice to understand the sentences.
thanks for the feedback! my aim is to make these things as accessible to the widest audience possible, and feedback like this helps me get better at doing so.
Great tutorial,
One minor thing it's that you should specify that at the toml file you need to specify the derive feature to be able to use it:
[dependencies]
clap = { version = "3.2.8", features = ["derive"] }
thanks and great point! I should have definitely included this.
@@codetothemoon Should honestly have showed the entire toml.
And I can't figure out what is the difference between the macros "clap" (which you used) and "command" (which the docs suggest using)
Thank you! I was wondering why my compiler was screaming when I did everything he said.
What perfect timing. I've been working on a CLI application and basing my argument parsing off one of the projects in the rust book. This looks much nicer to work with, even if I don't need nested arguments!
I agree, it's hard to make a case for not using Clap, even for smaller projects!
Excellent - thank you! I couldn't for the life of me figure out how to implement subcommands using the derive framework, and the builder method (the ony example I could find) produces code I find dense and hard to read. Perfect.
This tutorial is a gem in the dust! I love how you are the one who actually made a useful tutorial! Thank you!
Thank you. Your all vids are gem.
thanks for the kind words!
A crate "clap" for a language where the mascot is a crab is hilarious LOL
*panic*
I have a question: why create `struct UserCommand`? why not just create an make UserCommand as an enum. That extra stuct then enum step seems unnecessary. Please let me know your thoughts
This was an amazing video, short sweet and to the point. Very informative as well. I would say for future reference, you should probably show the set up of the project, even if it's brief. For example, someone really new to rust might not know that you actually have to add "features = ["derive"]" to their cargo.toml to work correctly. Other than that, great video!
Thanks Cheryl, glad you found it valuable. Great point about covering project setup - feature=["derive"] is a big gotcha!
Thxs for this explanation, it clarified me a lot how to define a CLI in rust. I would like to know how we can have bi-directional communication with the rust app and the command line. Could you please do an example of stdin / stdout with rust?
The sped up typing looks really satisfying, though I bet it was alot of work to do in video editing
Yeah it definitely makes editing take longer, but until I can type at 200wpm I don't want to make everyone sit there and watch me type 😎
Great tutorial & crate. Thanks for explanations!
Thanks, glad you found it valuable!
I love this crate.
Me too!
How do you allow for empty values? I want to use a single letter flag set to true when present and false when absent, but also allow for -z true and -z false
Greate tutorial.
For clap - can you elaborate on when to use the derive mechanism and when to use app creation?
Thanks! By app creation do you mean the builder API? If so my understanding is that it's mostly a personal preference thing, though it appears they have very slight differences in capability docs.rs/clap/latest/clap/#selecting-an-api
@@codetothemoon Yes, that's what I meant. Thanks!
Any way to make multiple names for the same command, like a semantics thing? say i wanted to create a file and wanted to accept if the command was either 'create' or 'touch'. maybe not important but would like to do it for fun or personal preference..
Great tutorial. Could you please share the link to the code repository :)
Sure here it is! github.com/Me163/youtube/tree/main/Rustflix
@@codetothemoon thanks
Hi, thanks for this content. Really really helpful for me.
I've been following your implementation of the Rustflix project and I'd like to serialize to JSON the values of `CreateView` or `UpdateVideo` structs (just to mention an example). I have tried several ways but have had no luck. Any hint?
Thanks in advance :)
Nice 👌
Thanks!!
but now, how to get the values?
the struct returned by RustflixArgs::parse() should be the struct you applied #[derive(Parser)] to, so you can just pull the values from there! I definitely glossed over this a bit too quickly at the end of the video.
How to get help menu if no argument is passed
Annotate your struct with
#[command(arg_required_else_help = true)]
Also, would be good if you can provide at least a Github gist of your codes lol, that should be basic.
github.com/Me163/youtube
The tutorial is great and helpful. But this American habit /accent to raise the voice at the end of a sentence to make it sound like a question is annoying. This sounds so confusing for a non-english speaker. You have to listen twice to understand the sentences.
thanks for the feedback! my aim is to make these things as accessible to the widest audience possible, and feedback like this helps me get better at doing so.
This was hard to follow, as you always scroll away, even if there is no need to.
Otherwise solid content.
You kinda look like a blond Elon Musk
hah! Sadly, I haven't slung quite as many things in orbit
I can’t unsee it