Replies: 1 comment 2 replies
-
Is the part where things went wrong the fact that we reference a struct named
The challenge is supporting all users without making the message so long no one reads it.
What we've been trying to teach in the documentation is the relationship between the derive and builder APIs. It isn't sustainable to ignore the builder API and document everything only for the derive, so we rely on teaching people to be able to translate concepts. We cover this in several ways in the derive reference though I can see some spots for improving it in the derive tutorial. We have #3189 for improving the documentation. |
Beta Was this translation helpful? Give feedback.
-
When compiling tealdeer CLI args, I got the following deprecation warning:
I'm using the derive based config:
With this approach, the deprecation warning left me a bit unsure on how to apply this change. What I did:
I tried simply adding
arg_required_else_help
to thecommand
argument:...and also:
...however, both attempts fail to compile because
command
is anArg
and not aCommand
.I searched the docs and looked at the method docs (including all examples), but that didn't really help.
Finally, I looked at the derive docs and found the section about raw attributes that made me realize that I could use
#[clap(arg_required_else_help(true))]
directly on the main struct.All in all, it took me maybe 10-15 minutes until I got it to work. However, it was not easy nor intuitive to find. My
Args
struct is not aCommand
, so it didn't really occur to me that I could apply command methods to it. In the end, the docs are there (when you look for them), and I got it to work, but maybe my experience can help in improving these deprecation warnings? I suspect that a big part of clap users will be using derive based args (in my opinion that's one of the most awesome parts of clap), so maybe the deprecation warnings could be improved to help those users?Beta Was this translation helpful? Give feedback.
All reactions