From ae60188eb9965b5669f35b48ebe9935e3ec82551 Mon Sep 17 00:00:00 2001 From: Dmitriy Morozov Date: Fri, 22 Sep 2017 16:32:59 -0700 Subject: [PATCH 1/2] Add --compact option to forget --- cmd/restic/cmd_forget.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/restic/cmd_forget.go b/cmd/restic/cmd_forget.go index e26e33696..9ba1963e5 100644 --- a/cmd/restic/cmd_forget.go +++ b/cmd/restic/cmd_forget.go @@ -35,9 +35,10 @@ type ForgetOptions struct { Yearly int KeepTags restic.TagLists - Host string - Tags restic.TagLists - Paths []string + Host string + Tags restic.TagLists + Paths []string + Compact bool // Grouping GroupBy string @@ -65,6 +66,7 @@ func init() { f.StringVar(&forgetOptions.Host, "hostname", "", "only consider snapshots with the given `hostname` (deprecated)") f.Var(&forgetOptions.Tags, "tag", "only consider snapshots which include this `taglist` in the format `tag[,tag,...]` (can be specified multiple times)") f.StringArrayVar(&forgetOptions.Paths, "path", nil, "only consider snapshots which include this (absolute) `path` (can be specified multiple times)") + f.BoolVarP(&forgetOptions.Compact, "compact", "c", false, "use compact format") f.StringVarP(&forgetOptions.GroupBy, "group-by", "g", "host,paths", "string for grouping snapshots by host,paths,tags") f.BoolVarP(&forgetOptions.DryRun, "dry-run", "n", false, "do not delete anything, just print what would be done") @@ -204,13 +206,13 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error { if len(keep) != 0 && !gopts.Quiet { Printf("keep %d snapshots:\n", len(keep)) - PrintSnapshots(globalOptions.stdout, keep, false) + PrintSnapshots(globalOptions.stdout, keep, opts.Compact) Printf("\n") } if len(remove) != 0 && !gopts.Quiet { Printf("remove %d snapshots:\n", len(remove)) - PrintSnapshots(globalOptions.stdout, remove, false) + PrintSnapshots(globalOptions.stdout, remove, opts.Compact) Printf("\n") } From efd65a1b6545652e774c5028621d90eae2de1f3f Mon Sep 17 00:00:00 2001 From: Dmitriy Morozov Date: Fri, 22 Sep 2017 16:35:58 -0700 Subject: [PATCH 2/2] Update manpage for forget --- doc/man/restic-forget.1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/man/restic-forget.1 b/doc/man/restic-forget.1 index 4e09a3df5..0a18e93f5 100644 --- a/doc/man/restic-forget.1 +++ b/doc/man/restic-forget.1 @@ -66,6 +66,10 @@ data after 'forget' was run successfully, see the 'prune' command. \fB\-\-path\fP=[] only consider snapshots which include this (absolute) \fB\fCpath\fR (can be specified multiple times) +.PP +\fB\-c\fP, \fB\-\-compact\fP[=false] + use compact format + .PP \fB\-g\fP, \fB\-\-group\-by\fP="host,paths" string for grouping snapshots by host,paths,tags