fetch.go 646 Bytes
Newer Older
ElyKar's avatar
ElyKar committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cmd

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

	"github.com/spf13/cobra"

	"dfss/dfssc/sign"
)

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)
		}
	},
}