コード例 #1
0
ファイル: arxclient.go プロジェクト: postfix/arx
func cliStore(cfg *arx.ClientConfig, args []string) {
	if len(args) != 2 {
		fmt.Println("Store requires two arguments: <ident> <secret key file>.")
		os.Exit(1)
	}
	ident := args[0]
	secret, err := ioutil.ReadFile(args[1])
	if err != nil {
		fmt.Println("Failed to read secret.")
		fmt.Printf("\t%v\n", err)
		os.Exit(1)
	}

	err = cfg.StoreSecret(ident, secret)
	if err != nil {
		fmt.Println("Request failed.")
		fmt.Printf("\t%v\n", err)
		os.Exit(1)
	}
	fmt.Println("OK.")
	os.Exit(0)
}