-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
tail/args: Fix parsing when -F is used together with --retry or --follow #4734
tail/args: Fix parsing when -F is used together with --retry or --follow #4734
Conversation
@tertsdiepraam This pr is ready :) |
@tertsdiepraam Could you review, please? |
src/uu/tail/src/args.rs
Outdated
(true, Some(value)) if value == "name" => (Some(FollowMode::Name), true), | ||
(true, Some(_)) => (Some(FollowMode::Descriptor), true), | ||
(true, None) => (Some(FollowMode::Name), true), | ||
(false, Some(value)) if value == "name" => { | ||
(Some(FollowMode::Name), matches.get_flag(options::RETRY)) | ||
} | ||
(false, Some(_)) => ( | ||
Some(FollowMode::Descriptor), | ||
matches.get_flag(options::RETRY), | ||
), | ||
(false, None) => (None, matches.get_flag(options::RETRY)), | ||
}; |
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.
please document the various cases
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.
done
6dd28bb
to
5cc3814
Compare
src/uu/tail/src/args.rs
Outdated
// * plain --follow or short -f is the same like specifying --follow=descriptor and can | ||
// overwrite itself (specified multiple times) | ||
// * specifying --retry together with -F doesn't change the setting of `retry` to true. The | ||
// --retry flag itself is restricted by clap to be specified only once (unlike gnu's tail) |
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't we match GNU by allowing retry multiple times?
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.
Sure. That's just the way it was before this pr and I wasn't sure. I think -F
should be allowed also multiple times
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.
To be fully compliant with gnu's tail, I think we should set clap_builder::builder::Command::args_override_self
to true globally for all arguments and not only for specific ones. Afaik, this is the way how they parse arguments. I could do this in another pr, maybe together with unit testing the arguments.
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.
Good idea! Let's do that separately indeed.
5cc3814
to
2f44fe5
Compare
2f44fe5
to
20e3297
Compare
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.
Nice!
This pr fixes the argument parsing when
-F
is used together with--retry
or--follow
.tail -F --retry
should not erase the implicit--follow
option,tail -F --follow
should not erase the implicit--retry
flag etc.