-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 option to limit snapshots list #3167
Conversation
e44134d
to
7995786
Compare
I didn't want to do deep changes with this patch. I am not sure that cobra allows to have flags with optional value. Ideally it would be better to reuse the
Not sure about the test, it seems that |
7995786
to
2135671
Compare
I agree that reusing the |
What would be the best option then? I can convert OTOH is it a problem to change Thanks for your feedback. |
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.
It would be possible to get --last=n
as parameter type. However, that looks like it could cause a lot of confusion, as we only use that variant for --verbose
.
After discussing with @rawtaz we arrived at the following suggestion: Name the parameter --latest n
instead of limit
and deprecate --last
, but make sure that it still works. Cobra supports this via something like f.MarkDeprecated("last", "use --latest 1")
.
fdfdc3c
to
ff6558e
Compare
This patch adds a `--latest` option to limit snapshots list to the n last snapshots. It is very similar to the `--last` one but does not limit to one entry. It also deprecates the `--last` flag usage in favor of `--latest 1` Output example: $ restic snapshots --latest 2 repository 0d3eb989 opened successfully, password is correct ID Time Host Tags Paths ------------------------------------------------------------ 5a33bdcc 2020-12-14 12:30:00 local /home 73887d8e 2020-12-15 12:30:00 local /home ------------------------------------------------------------ 2 snapshots Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
ff6558e
to
2a92b68
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.
LGTM. I've removed the man page modification and rebased the commit to the current master branch.
This patch adds a
--limit
option to limit snapshots list to the nlast snapshots. It is very similar to the
--last
one but does notlimit to one entry.
Output example:
To keep compatibility with previous versions a new function has been
added:
FilterSnapshotsWithLimit
. This function that filters a listof snapshots to only return the N last entries for each hostname and
path.
FilterLastSnapshots
callsFilterSnapshotsWithLimit(list, 1)
.Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
What does this PR change? What problem does it solve?
--last
option limit to the very last snapshot for each hosts. Insome case you want to show the n last snapshots. For example if you
want a weekly report of daily snapshots you cannot have this but by
using shell tools and wont report the correct number of snapshots.
This PR adds a
--limit
to limit display of the n last snapshots (seeabove).
Was the change discussed in an issue or in the forum before?
No.
Checklist
changelog/unreleased/
that describes the changes for our users (template here)gofmt
on the code in all commits