summaryrefslogtreecommitdiffstats
path: root/cmd/tuf/snapshot.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/tuf/snapshot.go')
-rw-r--r--cmd/tuf/snapshot.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/tuf/snapshot.go b/cmd/tuf/snapshot.go
new file mode 100644
index 0000000..dfffb69
--- /dev/null
+++ b/cmd/tuf/snapshot.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "github.com/flynn/go-docopt"
+ "github.com/theupdateframework/go-tuf"
+)
+
+func init() {
+ register("snapshot", cmdSnapshot, `
+usage: tuf snapshot [--expires=<days>]
+
+Update the snapshot metadata file.
+
+Alternatively, passphrases can be set via environment variables in the
+form of TUF_{{ROLE}}_PASSPHRASE
+
+Options:
+ --expires=<days> Set the snapshot metadata file to expire <days> days from now.
+`)
+}
+
+func cmdSnapshot(args *docopt.Args, repo *tuf.Repo) error {
+ if arg := args.String["--expires"]; arg != "" {
+ expires, err := parseExpires(arg)
+ if err != nil {
+ return err
+ }
+ return repo.SnapshotWithExpires(expires)
+ }
+ return repo.Snapshot()
+}