mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 23:08:01 -05:00
36 lines
746 B
Go
36 lines
746 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kopia/kopia/snapshot"
|
|
)
|
|
|
|
var (
|
|
policyCommands = app.Command("policy", "Commands to manipulate snapshotting policies.").Alias("policies")
|
|
)
|
|
|
|
func policyTargets(globalFlag *bool, targetsFlag *[]string) ([]*snapshot.SourceInfo, error) {
|
|
if *globalFlag == (len(*targetsFlag) > 0) {
|
|
return nil, fmt.Errorf("must pass either '--global' or a list of path targets")
|
|
}
|
|
|
|
if *globalFlag {
|
|
return []*snapshot.SourceInfo{
|
|
snapshot.GlobalPolicySourceInfo,
|
|
}, nil
|
|
}
|
|
|
|
var res []*snapshot.SourceInfo
|
|
for _, ts := range *targetsFlag {
|
|
target, err := snapshot.ParseSourceInfo(ts, getHostName(), getUserName())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
res = append(res, &target)
|
|
}
|
|
|
|
return res, nil
|
|
}
|