mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
28ba9b915b
Reviewed-on: https://gitea.com/gitea/tea/pulls/1006 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
45 lines
689 B
Go
45 lines
689 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package print
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.dev/sdk"
|
|
)
|
|
|
|
// SSHKeysList prints a table of SSH public keys
|
|
func SSHKeysList(keys []*gitea.PublicKey, output string) error {
|
|
if len(keys) == 0 {
|
|
fmt.Printf("No SSH keys found\n")
|
|
return nil
|
|
}
|
|
|
|
t := tableWithHeader(
|
|
"ID",
|
|
"Title",
|
|
"Fingerprint",
|
|
"KeyType",
|
|
"ReadOnly",
|
|
"Created",
|
|
)
|
|
|
|
for _, k := range keys {
|
|
readOnly := "false"
|
|
if k.ReadOnly {
|
|
readOnly = "true"
|
|
}
|
|
t.addRow(
|
|
fmt.Sprintf("%d", k.ID),
|
|
k.Title,
|
|
k.Fingerprint,
|
|
k.KeyType,
|
|
readOnly,
|
|
FormatTime(k.Created, false),
|
|
)
|
|
}
|
|
|
|
return t.print(output)
|
|
}
|