...

Source file src/github.com/theupdateframework/go-tuf/cmd/tuf-client/init.go

Documentation: github.com/theupdateframework/go-tuf/cmd/tuf-client

     1  package main
     2  
     3  import (
     4  	"io"
     5  	"os"
     6  
     7  	"github.com/flynn/go-docopt"
     8  	tuf "github.com/theupdateframework/go-tuf/client"
     9  )
    10  
    11  func init() {
    12  	register("init", cmdInit, `
    13  usage: tuf-client init [-s|--store=<path>] <url> [<root-metadata-file>]
    14  
    15  Options:
    16    -s <path>    The path to the local file store [default: tuf.db]
    17  
    18  Initialize the local file store with root metadata.
    19    `)
    20  }
    21  
    22  func cmdInit(args *docopt.Args, client *tuf.Client) error {
    23  	file := args.String["<root-metadata-file>"]
    24  	var in io.Reader
    25  	if file == "" || file == "-" {
    26  		in = os.Stdin
    27  	} else {
    28  		var err error
    29  		in, err = os.Open(file)
    30  		if err != nil {
    31  			return err
    32  		}
    33  	}
    34  	bytes, err := io.ReadAll(in)
    35  	if err != nil {
    36  		return err
    37  	}
    38  	return client.Init(bytes)
    39  }
    40  

View as plain text