| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
|
| 6 |
"github.com/flynn/go-docopt" |
| 7 |
"github.com/theupdateframework/go-tuf" |
| 8 |
) |
| 9 |
|
| 10 |
func init() { |
| 11 |
register("remove", cmdRemove, ` |
| 12 |
usage: tuf remove [--expires=<days>] [--all] [<path>...] |
| 13 |
|
| 14 |
Remove target file(s). |
| 15 |
|
| 16 |
Alternatively, passphrases can be set via environment variables in the |
| 17 |
form of TUF_{{ROLE}}_PASSPHRASE |
| 18 |
|
| 19 |
Options: |
| 20 |
--all Remove all target files. |
| 21 |
--expires=<days> Set the targets metadata file to expire <days> days from now. |
| 22 |
`) |
| 23 |
} |
| 24 |
|
| 25 |
func cmdRemove(args *docopt.Args, repo *tuf.Repo) error { |
| 26 |
paths := args.All["<path>"].([]string) |
| 27 |
if len(paths) == 0 && !args.Bool["--all"] { |
| 28 |
return errors.New("either specify some paths or set the --all flag to remove all targets") |
| 29 |
} |
| 30 |
if arg := args.String["--expires"]; arg != "" { |
| 31 |
expires, err := parseExpires(arg) |
| 32 |
if err != nil { |
| 33 |
return err |
| 34 |
} |
| 35 |
return repo.RemoveTargetsWithExpires(paths, expires) |
| 36 |
} |
| 37 |
return repo.RemoveTargets(paths) |
| 38 |
} |