mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 05:04:18 +02:00
Refactor output code, add JSON, TSV and YAML output modes, add -o (#19), add version subcommand
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"codeberg.org/scip/esctl/pkg/cfg"
|
||||
"codeberg.org/scip/esctl/pkg/printer"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -83,11 +84,11 @@ func SnapshotList(conf *cfg.Config) error {
|
||||
}
|
||||
}
|
||||
|
||||
table := NewTable(5, len(snapshots))
|
||||
table := printer.NewTable(conf, 5, len(snapshots))
|
||||
table.Addheaders("name", "index", "start", "orphaned", "status")
|
||||
|
||||
for idx, snap := range snapshots {
|
||||
table.entries[idx] = []string{
|
||||
table.Entries[idx] = []string{
|
||||
snap.Name,
|
||||
snap.Forindex,
|
||||
snap.Start,
|
||||
@@ -97,7 +98,7 @@ func SnapshotList(conf *cfg.Config) error {
|
||||
}
|
||||
|
||||
table.Sort()
|
||||
if err := table.PrintMarkdown(); err != nil {
|
||||
if err := table.Print(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -116,12 +117,12 @@ func SnapshotShow(conf *cfg.Config, snapshot string) error {
|
||||
return errors.New("no snapshot retrieved")
|
||||
}
|
||||
|
||||
table := NewTable(2, 17)
|
||||
table := printer.NewTable(conf, 2, 17)
|
||||
table.Addheaders("snapshot property", "value")
|
||||
|
||||
snap := res.Snapshots[0]
|
||||
|
||||
table.entries = [][]string{
|
||||
table.Entries = [][]string{
|
||||
{"snapshot", snapshot},
|
||||
{"uuid", snap.Uuid},
|
||||
{"repository", *snap.Repository},
|
||||
@@ -137,7 +138,7 @@ func SnapshotShow(conf *cfg.Config, snapshot string) error {
|
||||
{"shards-successful", fmt.Sprintf("%d", snap.Shards.Successful)},
|
||||
}
|
||||
|
||||
if err := table.PrintMarkdown(); err != nil {
|
||||
if err := table.Print(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user