| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
"os" |
| 6 |
"strconv" |
| 7 |
|
| 8 |
"github.com/flynn/go-docopt" |
| 9 |
"github.com/theupdateframework/go-tuf" |
| 10 |
) |
| 11 |
|
| 12 |
func init() { |
| 13 |
register("set-threshold", cmdSetThreshold, ` |
| 14 |
usage: tuf set-threshold <role> <threshold> |
| 15 |
|
| 16 |
Set the threshold for a role. |
| 17 |
`) |
| 18 |
} |
| 19 |
|
| 20 |
func cmdSetThreshold(args *docopt.Args, repo *tuf.Repo) error { |
| 21 |
role := args.String["<role>"] |
| 22 |
thresholdStr := args.String["<threshold>"] |
| 23 |
threshold, err := strconv.Atoi(thresholdStr) |
| 24 |
if err != nil { |
| 25 |
return err |
| 26 |
} |
| 27 |
|
| 28 |
if err := repo.SetThreshold(role, threshold); err != nil { |
| 29 |
return err |
| 30 |
} |
| 31 |
|
| 32 |
fmt.Fprintf(os.Stdout, "The threshold for %s role is now %d", role, threshold) |
| 33 |
return nil |
| 34 |
} |