|
|
|
@ -21,13 +21,33 @@ const (
@@ -21,13 +21,33 @@ const (
|
|
|
|
|
CHAT string = "chat" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// New returns a new Keybase
|
|
|
|
|
func New(opts ...KeybaseOpt) *Keybase { |
|
|
|
|
k := &Keybase{ExePath: "keybase"} |
|
|
|
|
|
|
|
|
|
for _, opt := range opts { |
|
|
|
|
opt.apply(k) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s := k.status() |
|
|
|
|
k.Version = k.version() |
|
|
|
|
k.LoggedIn = s.LoggedIn |
|
|
|
|
if k.LoggedIn { |
|
|
|
|
k.Username = s.Username |
|
|
|
|
k.Device = s.Device.Name |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return k |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NewKeybase returns a new Keybase. Optionally, you can pass a string containing the path to the Keybase executable as the first argument.
|
|
|
|
|
// This is deprecated and will be removed in a future update. Use New() instead.
|
|
|
|
|
func NewKeybase(path ...string) *Keybase { |
|
|
|
|
k := &Keybase{} |
|
|
|
|
if len(path) < 1 { |
|
|
|
|
k.Path = "keybase" |
|
|
|
|
k.ExePath = "keybase" |
|
|
|
|
} else { |
|
|
|
|
k.Path = path[0] |
|
|
|
|
k.ExePath = path[0] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s := k.status() |
|
|
|
@ -42,7 +62,15 @@ func NewKeybase(path ...string) *Keybase {
@@ -42,7 +62,15 @@ func NewKeybase(path ...string) *Keybase {
|
|
|
|
|
|
|
|
|
|
// Exec executes the given Keybase command
|
|
|
|
|
func (k *Keybase) Exec(command ...string) ([]byte, error) { |
|
|
|
|
out, err := exec.Command(k.Path, command...).Output() |
|
|
|
|
cmd := make([]string, 0) |
|
|
|
|
|
|
|
|
|
if k.HomePath != "" { |
|
|
|
|
cmd = append(cmd, "--home", k.HomePath) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cmd = append(cmd, command...) |
|
|
|
|
|
|
|
|
|
out, err := exec.Command(k.ExePath, cmd...).Output() |
|
|
|
|
if err != nil { |
|
|
|
|
return []byte{}, err |
|
|
|
|
} |
|
|
|
|