2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-27 07:16:40 +00:00

stats: add --mode completions

This commit is contained in:
Michael Eischer 2024-07-28 12:21:42 +02:00
parent bb50d86e68
commit 7448a15f72

View File

@ -70,10 +70,20 @@ type StatsOptions struct {
var statsOptions StatsOptions var statsOptions StatsOptions
func must(err error) {
if err != nil {
panic(fmt.Sprintf("error during setup: %v", err))
}
}
func init() { func init() {
cmdRoot.AddCommand(cmdStats) cmdRoot.AddCommand(cmdStats)
f := cmdStats.Flags() f := cmdStats.Flags()
f.StringVar(&statsOptions.countMode, "mode", countModeRestoreSize, "counting mode: restore-size (default), files-by-contents, blobs-per-file or raw-data") f.StringVar(&statsOptions.countMode, "mode", countModeRestoreSize, "counting mode: restore-size (default), files-by-contents, blobs-per-file or raw-data")
must(cmdStats.RegisterFlagCompletionFunc("mode", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{countModeRestoreSize, countModeUniqueFilesByContents, countModeBlobsPerFile, countModeRawData}, cobra.ShellCompDirectiveDefault
}))
initMultiSnapshotFilter(f, &statsOptions.SnapshotFilter, true) initMultiSnapshotFilter(f, &statsOptions.SnapshotFilter, true)
} }