-
Notifications
You must be signed in to change notification settings - Fork 972
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
Update arg parsing to clap v3 #1717
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
let root_dir = cli | ||
.root | ||
.canonicalize() | ||
.unwrap_or_else(|_| panic!("Cannot find root directory: {}", cli.root.display())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not handling the .
case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here cli.root
already has the .
value if it wasn't specified on the command line, so we handle only the canonicalize operation result, which I think should work for .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure it does work on all platforms, I'd like to be certain before changing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I built a small program to verify that canonicalizing .
works on windows, but if we wanted to be extra careful, there's the normpath crate that seems to be saner (also personally confirmed that it works).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep like you have for now, we'll see if it causes an issue
/// Include drafts when loading the site | ||
#[clap(long)] | ||
drafts: bool, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we be explicit with all the default values as well? eg set false
for drafts etc. I guess Subcommand
relies on default but I'd like to be able to see the full set of option values at a glance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've looked at the documentation, but especially for bool flags this is neither elegant to write nor widely accepted style to specify the default explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh :(
Just passing true/false to default doesn't work? It's kind of weird that non bool gets to have their default value in the struct but not bool since there are only 2 possible values...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick check and clap protests with a "default value is meaningless for bool" error.
I'm guessing the rationale is that bool flags are simple on-off switches and don't require any special handling.
@@ -13,14 +13,15 @@ keywords = ["static", "site", "generator", "blog"] | |||
include = ["src/**/*", "LICENSE", "README.md"] | |||
|
|||
[build-dependencies] | |||
clap = "2" | |||
clap = "3" | |||
clap_complete = "3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this do and where is it used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In v3 the completion functionality has been split off to the separate clap_complete
package, I noticed that there is some completion code in build.rs that is commented out, so admittedly this is a bit preemptive.
I guess we could instead add it in a separate PR focused on bringing back completion
The remaining issue is that clap v3 uses the |
Bumping the MSRV is not an issue but can that feature be disabled as it wouldn't be used anyway? |
I'm afraid building docs for dependencies can only be disabled in |
Oh I see, I thought clap was somehow pulling the readme in the built cli. This makes more sense. |
189c37d
to
6238b36
Compare
Can you resolve the conflicts? Or i'll do it later today |
4dcd6b6
to
0ee487d
Compare
Thanks! |
* Update arg parsing to clap v3
* Update arg parsing to clap v3
IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.
The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.
Switches arg parsing to the modern derive style via the newly released clap 3.0.0
Important/to discuss:
base_path
/base_url
parameters for thecheck
subcommand were read fromArgMatches
but never defined in the clap app, so I set them toNone
for nowSanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one: