From 24a2089db8eacb0dcdc32303bf36ee1999ce020f Mon Sep 17 00:00:00 2001 From: Todd Date: Wed, 14 Feb 2024 13:14:56 -0800 Subject: [PATCH] Add aliases to table format output for target reads (#4416) --- internal/cmd/commands/targetscmd/funcs.go | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/cmd/commands/targetscmd/funcs.go b/internal/cmd/commands/targetscmd/funcs.go index 549a1e0e1f..c0a9c69c97 100644 --- a/internal/cmd/commands/targetscmd/funcs.go +++ b/internal/cmd/commands/targetscmd/funcs.go @@ -593,6 +593,20 @@ func printItemTable(item *targets.Target, resp *api.Response) string { } } + var aliasMaps []map[string]any + if len(item.Aliases) > 0 { + for _, al := range item.Aliases { + m := map[string]any{ + "ID": al.Id, + "Value": al.Value, + } + aliasMaps = append(aliasMaps, m) + } + if l := len("Value"); l > maxLength { + maxLength = l + } + } + ret := []string{ "", "Target information:", @@ -619,6 +633,18 @@ func printItemTable(item *targets.Target, resp *api.Response) string { "", ) + if len(aliasMaps) > 0 { + ret = append(ret, + " Aliases:", + ) + for _, m := range aliasMaps { + ret = append(ret, + base.WrapMap(4, maxLength, m), + "", + ) + } + } + if len(hostSourceMaps) > 0 { ret = append(ret, " Host Sources:",