mirror of
https://github.com/kopia/kopia.git
synced 2026-01-02 19:47:51 -05:00
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'
32 lines
732 B
Go
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))
|
|
}
|