snapshot of https://github.com/ory/keto.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
CI / Run lints and checks (push) Failing after 47s
CI / Run tests (push) Failing after 1s
CI / Run race tests (push) Failing after 5s
CI / Build CLI docs (push) Has been skipped
CI / Run buf actions (push) Failing after 5s
CodeQL / Analyze (go) (push) Failing after 3s
CodeQL / Analyze (javascript) (push) Failing after 2s
Docker Image Scanners / scanners (push) Failing after 3s
Format / format (push) Failing after 3s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Draft newsletter (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run lints and checks (push) Failing after 47s
CI / Run tests (push) Failing after 1s
CI / Run race tests (push) Failing after 5s
CI / Build CLI docs (push) Has been skipped
CI / Run buf actions (push) Failing after 5s
CodeQL / Analyze (go) (push) Failing after 3s
CodeQL / Analyze (javascript) (push) Failing after 2s
Docker Image Scanners / scanners (push) Failing after 3s
Format / format (push) Failing after 3s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Draft newsletter (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
84
oryx/cmdx/output.go
Normal file
84
oryx/cmdx/output.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright © 2023 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package cmdx
|
||||
|
||||
import "strconv"
|
||||
|
||||
type (
|
||||
// OutputIder outputs an ID
|
||||
OutputIder string
|
||||
// OutputIderCollection outputs a list of IDs
|
||||
OutputIderCollection struct {
|
||||
Items []OutputIder
|
||||
}
|
||||
)
|
||||
|
||||
func (OutputIder) Header() []string {
|
||||
return []string{"ID"}
|
||||
}
|
||||
|
||||
func (i OutputIder) Columns() []string {
|
||||
return []string{string(i)}
|
||||
}
|
||||
|
||||
func (i OutputIder) Interface() interface{} {
|
||||
return i
|
||||
}
|
||||
|
||||
func (OutputIderCollection) Header() []string {
|
||||
return []string{"ID"}
|
||||
}
|
||||
|
||||
func (c OutputIderCollection) Table() [][]string {
|
||||
rows := make([][]string, len(c.Items))
|
||||
for i, ident := range c.Items {
|
||||
rows[i] = []string{string(ident)}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
func (c OutputIderCollection) Interface() interface{} {
|
||||
return c.Items
|
||||
}
|
||||
|
||||
func (c OutputIderCollection) Len() int {
|
||||
return len(c.Items)
|
||||
}
|
||||
|
||||
type PaginatedList struct {
|
||||
Collection interface {
|
||||
Table
|
||||
IDs() []string
|
||||
} `json:"-"`
|
||||
Items []interface{} `json:"items"`
|
||||
NextPageToken string `json:"next_page_token"`
|
||||
IsLastPage bool `json:"is_last_page"`
|
||||
}
|
||||
|
||||
func (r *PaginatedList) Header() []string {
|
||||
return r.Collection.Header()
|
||||
}
|
||||
|
||||
func (r *PaginatedList) Table() [][]string {
|
||||
return append(
|
||||
r.Collection.Table(),
|
||||
[]string{},
|
||||
[]string{"NEXT PAGE TOKEN", r.NextPageToken},
|
||||
[]string{"IS LAST PAGE", strconv.FormatBool(r.IsLastPage)},
|
||||
)
|
||||
}
|
||||
|
||||
func (r *PaginatedList) Interface() interface{} {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *PaginatedList) Len() int {
|
||||
return r.Collection.Len() + 3
|
||||
}
|
||||
|
||||
func (r *PaginatedList) IDs() []string {
|
||||
return r.Collection.IDs()
|
||||
}
|
||||
|
||||
var _ Table = (*PaginatedList)(nil)
|
||||
Reference in New Issue
Block a user