fetch.go 645 Bytes
Newer Older
ElyKar's avatar
ElyKar committed
1
2
3
4
5
6
7
8
package cmd

import (
	"fmt"
	"os"
	"path/filepath"

	"dfss/dfssc/sign"
9
	"github.com/spf13/cobra"
ElyKar's avatar
ElyKar committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
)

var fetchCmd = &cobra.Command{
	Use:   "fetch",
	Short: "get a contract hosted on the platform",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Fetching a saved contract")

		var passphrase, uuid, directory string
		_ = readPassword(&passphrase, false)
		readStringParam("Contract UUID", "", &uuid)
		readStringParam("Save directory", ".", &directory)

		path := filepath.Join(directory, uuid+".json")
		err := sign.FetchContract(passphrase, uuid, path)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}
	},
}