|
|
@ -29,6 +29,7 @@ func NewKeybase(path ...string) *Keybase { |
|
|
|
k.LoggedIn = k.loggedIn() |
|
|
|
k.LoggedIn = k.loggedIn() |
|
|
|
if k.LoggedIn { |
|
|
|
if k.LoggedIn { |
|
|
|
k.Username = k.username() |
|
|
|
k.Username = k.username() |
|
|
|
|
|
|
|
k.Device = k.device() |
|
|
|
} |
|
|
|
} |
|
|
|
return k |
|
|
|
return k |
|
|
|
} |
|
|
|
} |
|
|
@ -78,6 +79,19 @@ func (k *Keybase) username() string { |
|
|
|
return s.Username |
|
|
|
return s.Username |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// device returns the device name of the currently provisioned device.
|
|
|
|
|
|
|
|
func (k *Keybase) device() string { |
|
|
|
|
|
|
|
cmdOut, err := k.Exec("status", "-j") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return "" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var s status |
|
|
|
|
|
|
|
json.Unmarshal(cmdOut, &s) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return s.Device.Name |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// loggedIn returns true if Keybase is currently logged in, otherwise returns false.
|
|
|
|
// loggedIn returns true if Keybase is currently logged in, otherwise returns false.
|
|
|
|
func (k *Keybase) loggedIn() bool { |
|
|
|
func (k *Keybase) loggedIn() bool { |
|
|
|
cmdOut, err := k.Exec("status", "-j") |
|
|
|
cmdOut, err := k.Exec("status", "-j") |
|
|
|