-
Notifications
You must be signed in to change notification settings - Fork 13
/
agent.go
42 lines (35 loc) · 1.04 KB
/
agent.go
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
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2019 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package main
import (
"os/exec"
)
const (
passwordTag = "bitmark-cli:password:"
)
// expect to execute agent with parameters
// --confirm=1 - for additional confirm
// cache-id - alows password to be cached for a time
// error-message - blank
// prompt - names the identity
// description - shows create/transfer operation
func passwordFromAgent(name string, title string, agent string, clear bool) (string, error) {
cacheId := passwordTag + name
errorMessage := ""
prompt := "Password for: " + name
description := "Enter password to: " + title
arguments := []string{}
if clear {
arguments = append(arguments, "--clear")
}
arguments = append(arguments, []string{
"--confirm=1",
cacheId,
errorMessage,
prompt,
description}...)
out, err := exec.Command(agent, arguments...).Output()
return string(out), err
}