Files
kopia/cli/command_content_range_flags.go
Jarek Kowalski 70d4c8764a cli: improvements to content selection for list/rewrite/stats/verify (#409)
They now uniformly support 3 flags:

--prefix=P       selects contents with the specified prefix
--prefixed       selects contents with ANY prefix
--non-prefixed   selects non-prefixed contents

Also changed content manager iteration API to support ranges.

cli: add --prefix to 'blob gc' and 'blob stats'
2020-04-06 18:43:41 -07:00

32 lines
732 B
Go

package cli
import (
"gopkg.in/alecthomas/kingpin.v2"
"github.com/kopia/kopia/repo/content"
)
var (
contentIDPrefix string
contentIDNonPrefixed bool
contentIDPrefixed bool
)
func setupContentIDRangeFlags(cmd *kingpin.CmdClause) {
cmd.Flag("prefix", "Content ID prefix").StringVar(&contentIDPrefix)
cmd.Flag("prefixed", "Apply to content IDs with (any) prefix").BoolVar(&contentIDPrefixed)
cmd.Flag("non-prefixed", "Apply to content IDs without prefix").BoolVar(&contentIDNonPrefixed)
}
func contentIDRange() content.IDRange {
if contentIDPrefixed {
return content.AllPrefixedIDs
}
if contentIDNonPrefixed {
return content.AllNonPrefixedIDs
}
return content.PrefixRange(content.ID(contentIDPrefix))
}