diff --git a/pkg/cmd/list/cache_setting/cache_setting.go b/pkg/cmd/list/cache_setting/cache_setting.go index 9b19aaf4d..af9fbec75 100644 --- a/pkg/cmd/list/cache_setting/cache_setting.go +++ b/pkg/cmd/list/cache_setting/cache_setting.go @@ -76,19 +76,29 @@ func PrintTable(cmd *cobra.Command, f *cmdutil.Factory, opts *contracts.ListOpti listOut.Out = f.IOStreams.Out listOut.Flags = f.Flags - if cmd.Flags().Changed("details") { + if opts.Details { listOut.Columns = []string{"ID", "NAME", "BROWSER CACHE SETTINGS", "CDN CACHE SETTINGS", "CACHE BY COOKIES", "ENABLE CACHING FOR POST"} } for _, v := range cache.Results { - ln := []string{ - fmt.Sprintf("%d", v.Id), - v.Name, - v.BrowserCacheSettings, - v.CdnCacheSettings, - v.CacheByCookies, - fmt.Sprintf("%v", v.EnableCachingForPost), + ln := []string{} + if opts.Details { + ln = []string{ + fmt.Sprintf("%d", v.Id), + v.Name, + v.BrowserCacheSettings, + v.CdnCacheSettings, + v.CacheByCookies, + fmt.Sprintf("%v", v.EnableCachingForPost), + } + } else { + ln = []string{ + fmt.Sprintf("%d", v.Id), + v.Name, + v.BrowserCacheSettings, + } } + listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/domain/domain.go b/pkg/cmd/list/domain/domain.go index 78d602fdd..9ad654d84 100644 --- a/pkg/cmd/list/domain/domain.go +++ b/pkg/cmd/list/domain/domain.go @@ -57,16 +57,25 @@ func PrintTable(cmd *cobra.Command, f *cmdutil.Factory, opts *contracts.ListOpti } for _, v := range resp.Results { - ln := []string{ - fmt.Sprintf("%d", v.GetId()), - utils.TruncateString(v.GetName()), - v.GetDomainName(), - fmt.Sprintf("%d", v.GetDigitalCertificateId()), - fmt.Sprintf("%d", v.GetDigitalCertificateId()), - fmt.Sprintf("%v", v.GetCnameAccessOnly()), - fmt.Sprintf("%v", v.GetCnames()), - fmt.Sprintf("%v", v.GetIsActive()), + ln := []string{} + if opts.Details { + ln = []string{ + fmt.Sprintf("%d", v.GetId()), + utils.TruncateString(v.GetName()), + v.GetDomainName(), + fmt.Sprintf("%d", v.GetDigitalCertificateId()), + fmt.Sprintf("%d", v.GetDigitalCertificateId()), + fmt.Sprintf("%v", v.GetCnameAccessOnly()), + fmt.Sprintf("%v", v.GetCnames()), + fmt.Sprintf("%v", v.GetIsActive()), + } + } else { + ln = []string{ + fmt.Sprintf("%d", v.GetId()), + utils.TruncateString(v.GetName()), + } } + listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/edge_applications/edge_applications.go b/pkg/cmd/list/edge_applications/edge_applications.go index d1551e2a7..34d14a2fd 100644 --- a/pkg/cmd/list/edge_applications/edge_applications.go +++ b/pkg/cmd/list/edge_applications/edge_applications.go @@ -66,14 +66,24 @@ func PrintTable(cmd *cobra.Command, client *api.Client, f *cmdutil.Factory, opts } for _, v := range resp.Results { - ln := []string{ - fmt.Sprintf("%d", v.Id), - utils.TruncateString(v.Name), - fmt.Sprintf("%v", v.Active), - v.LastEditor, - v.LastModified, - fmt.Sprintf("%v", v.DebugRules), + ln := []string{} + if opts.Details { + ln = []string{ + fmt.Sprintf("%d", v.Id), + utils.TruncateString(v.Name), + fmt.Sprintf("%v", v.Active), + v.LastEditor, + v.LastModified, + fmt.Sprintf("%v", v.DebugRules), + } + } else { + ln = []string{ + fmt.Sprintf("%d", v.Id), + utils.TruncateString(v.Name), + fmt.Sprintf("%v", v.Active), + } } + listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/edge_function/edge_function.go b/pkg/cmd/list/edge_function/edge_function.go index a13b4ab53..8a4224f38 100644 --- a/pkg/cmd/list/edge_function/edge_function.go +++ b/pkg/cmd/list/edge_function/edge_function.go @@ -62,15 +62,25 @@ func PrintTable(cmd *cobra.Command, f *cmdutil.Factory, opts *contracts.ListOpti } for _, v := range functions.Results { - ln := []string{ - fmt.Sprintf("%d", v.GetId()), - v.GetName(), - v.GetLanguage(), - fmt.Sprintf("%v", v.GetActive()), - v.GetLastEditor(), - v.GetModified(), - fmt.Sprintf("%d", v.GetReferenceCount()), - v.GetInitiatorType(), + ln := []string{} + if opts.Details { + ln = []string{ + fmt.Sprintf("%d", v.GetId()), + v.GetName(), + v.GetLanguage(), + fmt.Sprintf("%v", v.GetActive()), + v.GetLastEditor(), + v.GetModified(), + fmt.Sprintf("%d", v.GetReferenceCount()), + v.GetInitiatorType(), + } + } else { + ln = []string{ + fmt.Sprintf("%d", v.GetId()), + v.GetName(), + v.GetLanguage(), + fmt.Sprintf("%v", v.GetActive()), + } } listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/edge_storage/object.go b/pkg/cmd/list/edge_storage/object.go index 8ad41cb08..333ecc207 100644 --- a/pkg/cmd/list/edge_storage/object.go +++ b/pkg/cmd/list/edge_storage/object.go @@ -85,11 +85,19 @@ func (b *Objects) PrintTable(client *api.Client) error { } for _, v := range resp.Results { - ln := []string{ - v.GetKey(), - fmt.Sprintf("%v", v.GetLastModified()), - fmt.Sprintf("%v", v.GetSize()), - v.GetEtag(), + ln := []string{} + if b.Options.Details { + ln = []string{ + v.GetKey(), + fmt.Sprintf("%v", v.GetLastModified()), + fmt.Sprintf("%v", v.GetSize()), + v.GetEtag(), + } + } else { + ln = []string{ + v.GetKey(), + fmt.Sprintf("%v", v.GetLastModified()), + } } listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/origin/origin.go b/pkg/cmd/list/origin/origin.go index 198799d66..f3afcfff9 100644 --- a/pkg/cmd/list/origin/origin.go +++ b/pkg/cmd/list/origin/origin.go @@ -82,14 +82,22 @@ func PrintTable(client *api.Client, f *cmdutil.Factory, opts *contracts.ListOpti } for _, v := range resp.Results { - ln := []string{ - *v.OriginKey, - utils.TruncateString(v.Name), - fmt.Sprintf("%d", *v.OriginId), - *v.OriginType, - *v.OriginPath, - fmt.Sprintf("%v", v.Addresses), - fmt.Sprintf("%d", *v.ConnectionTimeout), + ln := []string{} + if opts.Details { + ln = []string{ + *v.OriginKey, + utils.TruncateString(v.Name), + fmt.Sprintf("%d", *v.OriginId), + *v.OriginType, + *v.OriginPath, + fmt.Sprintf("%v", v.Addresses), + fmt.Sprintf("%d", *v.ConnectionTimeout), + } + } else { + ln = []string{ + *v.OriginKey, + utils.TruncateString(v.Name), + } } listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/personal_token/personal_token.go b/pkg/cmd/list/personal_token/personal_token.go index 31b81e78c..b198be3c7 100644 --- a/pkg/cmd/list/personal_token/personal_token.go +++ b/pkg/cmd/list/personal_token/personal_token.go @@ -64,17 +64,26 @@ func PrintTable(client *api.Client, f *cmdutil.Factory, details bool) error { } for _, v := range resp { - var description string - if v.Description.Get() != nil { - description = *v.Description.Get() - } - ln := []string{ - *v.Uuid, - utils.TruncateString(*v.Name), - v.ExpiresAt.Format(constants.FORMAT_DATE), - fmt.Sprintf("%v", *v.Created), - utils.TruncateString(description), + ln := []string{} + if details { + var description string + if v.Description.Get() != nil { + description = *v.Description.Get() + } + ln = []string{ + *v.Uuid, + utils.TruncateString(*v.Name), + v.ExpiresAt.Format(constants.FORMAT_DATE), + fmt.Sprintf("%v", *v.Created), + utils.TruncateString(description), + } + } else { + ln = []string{ + *v.Uuid, + utils.TruncateString(*v.Name), + v.ExpiresAt.Format(constants.FORMAT_DATE), + } } listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/rule_engine/rule_engine.go b/pkg/cmd/list/rule_engine/rule_engine.go index 25efdc112..ede48c64f 100644 --- a/pkg/cmd/list/rule_engine/rule_engine.go +++ b/pkg/cmd/list/rule_engine/rule_engine.go @@ -88,17 +88,25 @@ func PrintTable(cmd *cobra.Command, f *cmdutil.Factory, opts *contracts.ListOpti listOut.Out = f.IOStreams.Out listOut.Flags = f.Flags - if cmd.Flags().Changed("details") { + if opts.Details { listOut.Columns = []string{"ID", "NAME", "ORDER", "PHASE", "ACTIVE"} } for _, v := range rules.Results { - ln := []string{ - fmt.Sprintf("%d", v.Id), - v.Name, - fmt.Sprintf("%d", v.Order), - v.Phase, - fmt.Sprintf("%v", v.IsActive), + ln := []string{} + if opts.Details { + ln = []string{ + fmt.Sprintf("%d", v.Id), + v.Name, + fmt.Sprintf("%d", v.Order), + v.Phase, + fmt.Sprintf("%v", v.IsActive), + } + } else { + ln = []string{ + fmt.Sprintf("%d", v.Id), + v.Name, + } } listOut.Lines = append(listOut.Lines, ln) } diff --git a/pkg/cmd/list/variables/variables.go b/pkg/cmd/list/variables/variables.go index aac467ac0..b5d12b31d 100644 --- a/pkg/cmd/list/variables/variables.go +++ b/pkg/cmd/list/variables/variables.go @@ -82,12 +82,21 @@ func listAllVariables(client *api.Client, f *cmdutil.Factory, opts *contracts.Li } for _, v := range resp { - ln := []string{ - v.GetUuid(), - v.GetKey(), - utils.TruncateString(v.GetValue()), - fmt.Sprintf("%v", v.GetSecret()), - v.GetLastEditor(), + ln := []string{} + if opts.Details { + ln = []string{ + v.GetUuid(), + v.GetKey(), + utils.TruncateString(v.GetValue()), + fmt.Sprintf("%v", v.GetSecret()), + v.GetLastEditor(), + } + } else { + ln = []string{ + v.GetUuid(), + v.GetKey(), + utils.TruncateString(v.GetValue()), + } } listOut.Lines = append(listOut.Lines, ln)