Example #1
0
func displayTable(entries []keybase1.UserSummary, verbose bool, headers bool) (err error) {
	if verbose {
		noun := "users"
		if len(entries) == 1 {
			noun = "user"
		}
		GlobUI.Printf("Tracking %d %s:\n\n", len(entries), noun)
	}

	var cols []string

	if headers {
		if verbose {
			cols = []string{
				"Username",
				"Sig ID",
				"PGP fingerprints",
				"When Tracked",
				"Proofs",
			}
		} else {
			cols = []string{"Username"}
		}
	}

	i := 0
	rowfunc := func() []string {
		if i >= len(entries) {
			return nil
		}
		entry := entries[i]
		i++

		if !verbose {
			return []string{entry.Username}
		}

		fps := make([]string, len(entry.Proofs.PublicKeys))
		for i, k := range entry.Proofs.PublicKeys {
			if k.PGPFingerprint != "" {
				fps[i] = k.PGPFingerprint
			}
		}

		row := []string{
			entry.Username,
			entry.SigIDDisplay,
			strings.Join(fps, ", "),
			keybase1.FormatTime(entry.TrackTime),
		}
		for _, proof := range entry.Proofs.Social {
			row = append(row, proof.IdString)
		}
		return row
	}

	GlobUI.Tablify(cols, rowfunc)
	return
}
Example #2
0
func (s *CmdSigsList) DisplayKTable(sigs []keybase1.Sig) (err error) {
	if sigs == nil {
		return nil
	}

	var cols []string

	if s.headers {
		cols = []string{
			"#",
			"SigId",
			"Type",
			"Date",
		}
		if s.revoked {
			cols = append(cols, "Revoked")
		}
		if s.allKeys {
			cols = append(cols, "Active", "Key")
		}
		cols = append(cols, "Body")
	}

	i := 0

	rowfunc := func() []string {
		var row []string
		for ; i < len(sigs) && row == nil; i++ {
			link := sigs[i]
			row = []string{
				fmt.Sprintf("%d", link.Seqno),
				link.SigIDDisplay,
				link.Type,
				keybase1.FormatTime(link.CTime),
			}
			if s.revoked {
				var ch string
				if link.Revoked {
					ch = "R"
				} else {
					ch = "."
				}
				row = append(row, ch)
			}
			if s.allKeys {
				var ch string
				if link.Active {
					ch = "+"
				} else {
					ch = "-"
				}
				row = append(row, ch, link.Key)
			}
			row = append(row, link.Body)
		}
		return row
	}

	GlobUI.Tablify(cols, rowfunc)

	return
}