// RunClient runs the command in client/server mode.
func (c *CmdListTrackers) Run() error {
	cli, err := GetUserClient()
	if err != nil {
		return err
	}
	if err := RegisterProtocols(nil); err != nil {
		return err
	}

	var trs []keybase1.Tracker
	if c.uid.Exists() {
		trs, err = cli.ListTrackers(context.TODO(), keybase1.ListTrackersArg{Uid: c.uid})
	} else if len(c.username) > 0 {
		trs, err = cli.ListTrackersByName(context.TODO(), keybase1.ListTrackersByNameArg{Username: c.username})
	} else {
		trs, err = cli.ListTrackersSelf(context.TODO(), 0)
	}
	if err != nil {
		return err
	}

	summarize := func(uids []keybase1.UID) (res []keybase1.UserSummary, err error) {
		return cli.LoadUncheckedUserSummaries(context.TODO(), keybase1.LoadUncheckedUserSummariesArg{Uids: uids})
	}

	return c.output(trs, summarize)
}
示例#2
0
func UserSummariesForSearchResults(results []keybase1.SearchResult) ([]keybase1.UserSummary, error) {
	cli, err := GetUserClient()
	if err != nil {
		return nil, err
	}

	uids := make([]keybase1.UID, len(results))
	for i := range results {
		uids[i] = results[i].Uid
	}
	userSummaries, err := cli.LoadUncheckedUserSummaries(context.TODO(), keybase1.LoadUncheckedUserSummariesArg{Uids: uids})
	if err != nil {
		return nil, err
	}
	return userSummaries, nil
}
示例#3
0
文件: cmd_search.go 项目: qbit/client
func UserSummariesForSearchResults(results []keybase1.SearchResult,
	g *libkb.GlobalContext) ([]keybase1.UserSummary, error) {

	cli, err := GetUserClient(g)
	if err != nil {
		return nil, err
	}
	// Don't bother if no results.
	if len(results) == 0 {
		return nil, nil
	}

	uids := make([]keybase1.UID, len(results))
	for i := range results {
		uids[i] = results[i].Uid
	}
	userSummaries, err := cli.LoadUncheckedUserSummaries(context.TODO(), keybase1.LoadUncheckedUserSummariesArg{Uids: uids})
	if err != nil {
		return nil, err
	}
	return userSummaries, nil
}