| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/flynn/go-docopt" |
| 5 |
"github.com/theupdateframework/go-tuf" |
| 6 |
) |
| 7 |
|
| 8 |
func init() { |
| 9 |
register("snapshot", cmdSnapshot, ` |
| 10 |
usage: tuf snapshot [--expires=<days>] |
| 11 |
|
| 12 |
Update the snapshot metadata file. |
| 13 |
|
| 14 |
Alternatively, passphrases can be set via environment variables in the |
| 15 |
form of TUF_{{ROLE}}_PASSPHRASE |
| 16 |
|
| 17 |
Options: |
| 18 |
--expires=<days> Set the snapshot metadata file to expire <days> days from now. |
| 19 |
`) |
| 20 |
} |
| 21 |
|
| 22 |
func cmdSnapshot(args *docopt.Args, repo *tuf.Repo) error { |
| 23 |
if arg := args.String["--expires"]; arg != "" { |
| 24 |
expires, err := parseExpires(arg) |
| 25 |
if err != nil { |
| 26 |
return err |
| 27 |
} |
| 28 |
return repo.SnapshotWithExpires(expires) |
| 29 |
} |
| 30 |
return repo.Snapshot() |
| 31 |
} |