Repository: knative/client
Pull request #582 (2019-12-20 03:33:56)

Use the same flag definition for list command of list_type, service and route
## Proposed Changes

* Remove redundant code for list flag definition under list_type, service and route
* Use the same flag defined in `listprint.go` under `pkg/kn/commands/flags` for list command of `list_type`, `service` and `route`.
* Rename the list flag from `ListFlags` to `ListPrintFlags` for better description.

knative-prow-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/582#" title="Author self-approved">daisy-ycguo</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **maximilien**
You can assign the PR to them by writing `/assign @maximilien` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/knative/client/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["maximilien"]} -->
knative-metrics-robot: The following is the coverage report on the affected files.
Say `/test pull-knative-client-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/kn/commands/flags/listprint.go](https://storage.cloud.google.com/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-go-coverage/1207866746053070848/artifacts/line-cov.html#file0) | Do not exist | 62.5% | 

knative-prow-robot: @daisy-ycguo: The following test **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-client-integration-tests | c5a93465f8231607278ce3216e9d86d9cc07ca36 | [link](https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-integration-tests/1207866746053070849) | `/test pull-knative-client-integration-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_client/582). [Your PR dashboard](https://gubernator.knative.dev/pr/daisy-ycguo).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
daisy-ycguo: /test pull-knative-client-integration-tests
knative-prow-robot: @daisy-ycguo: The following test **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-client-integration-tests-latest-release | 250e1061f88b01c3ed19a25b07284cfeee0a4bc4 | [link](https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-integration-tests-latest-release/1207956969046937600) | `/test pull-knative-client-integration-tests-latest-release`

[Full PR test history](https://gubernator.knative.dev/pr/knative_client/582). [Your PR dashboard](https://gubernator.knative.dev/pr/daisy-ycguo).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
knative-prow-robot: @daisy-ycguo: The following tests **failed**, say `/retest` to rerun them all:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-client-integration-tests-latest-release | 250e1061f88b01c3ed19a25b07284cfeee0a4bc4 | [link](https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-integration-tests-latest-release/1207956969046937600) | `/test pull-knative-client-integration-tests-latest-release`
pull-knative-client-integration-tests | 250e1061f88b01c3ed19a25b07284cfeee0a4bc4 | [link](https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-integration-tests/1207956969055326209) | `/test pull-knative-client-integration-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_client/582). [Your PR dashboard](https://gubernator.knative.dev/pr/daisy-ycguo).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
knative-metrics-robot: The following is the coverage report on the affected files.
Say `/test pull-knative-client-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/kn/commands/flags/listprint.go](https://storage.cloud.google.com/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-go-coverage/1207956969051131904/artifacts/line-cov.html#file0) | Do not exist | 62.5% | 

knative-metrics-robot: The following is the coverage report on the affected files.
Say `/test pull-knative-client-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[pkg/kn/commands/flags/listprint.go](https://storage.cloud.google.com/knative-prow/pr-logs/pull/knative_client/582/pull-knative-client-go-coverage/1207957473185501184/artifacts/line-cov.html#file0) | Do not exist | 62.5% | 

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/client/pull/582#" title="Author self-approved">daisy-ycguo</a>*, *<a href="https://github.com/knative/client/pull/582#pullrequestreview-335238823" title="Approved">rhuss</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fclient).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative/client/blob/master/OWNERS)~~ [rhuss]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/kn/commands/flags/list.go b/pkg/kn/commands/flags/listprint.go
similarity index 86%
rename from pkg/kn/commands/flags/list.go
rename to pkg/kn/commands/flags/listprint.go
index 5e336f32..422de694 100644
--- a/pkg/kn/commands/flags/list.go
+++ b/pkg/kn/commands/flags/listprint.go
@@ -23,14 +23,14 @@ import (
 
 // ListFlags composes common printer flag structs
 // used in the list command.
-type ListFlags struct {
+type ListPrintFlags struct {
 	GenericPrintFlags  *genericclioptions.PrintFlags
 	HumanReadableFlags *commands.HumanPrintFlags
 	PrinterHandler     func(h hprinters.PrintHandler)
 }
 
 // AllowedFormats is the list of formats in which data can be displayed
-func (f *ListFlags) AllowedFormats() []string {
+func (f *ListPrintFlags) AllowedFormats() []string {
 	formats := f.GenericPrintFlags.AllowedFormats()
 	formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
 	return formats
@@ -38,7 +38,7 @@ func (f *ListFlags) AllowedFormats() []string {
 
 // ToPrinter attempts to find a composed set of ListTypesFlags suitable for
 // returning a printer based on current flag values.
-func (f *ListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
+func (f *ListPrintFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
 	// if there are flags specified for generic printing
 	if f.GenericPrintFlags.OutputFlagSpecified() {
 		p, err := f.GenericPrintFlags.ToPrinter()
@@ -57,15 +57,15 @@ func (f *ListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
 
 // AddFlags receives a *cobra.Command reference and binds
 // flags related to humanreadable and template printing.
-func (f *ListFlags) AddFlags(cmd *cobra.Command) {
+func (f *ListPrintFlags) AddFlags(cmd *cobra.Command) {
 	f.GenericPrintFlags.AddFlags(cmd)
 	f.HumanReadableFlags.AddFlags(cmd)
 }
 
 // NewListFlags returns flags associated with humanreadable,
 // template, and "name" printing, with default values set.
-func NewListFlags(printer func(h hprinters.PrintHandler)) *ListFlags {
-	return &ListFlags{
+func NewListPrintFlags(printer func(h hprinters.PrintHandler)) *ListPrintFlags {
+	return &ListPrintFlags{
 		GenericPrintFlags:  genericclioptions.NewPrintFlags(""),
 		HumanReadableFlags: commands.NewHumanPrintFlags(),
 		PrinterHandler:     printer,
@@ -74,6 +74,6 @@ func NewListFlags(printer func(h hprinters.PrintHandler)) *ListFlags {
 
 // EnsureWithNamespace ensures that humanreadable flags return
 // a printer capable of printing with a "namespace" column.
-func (f *ListFlags) EnsureWithNamespace() {
+func (f *ListPrintFlags) EnsureWithNamespace() {
 	f.HumanReadableFlags.EnsureWithNamespace()
 }
diff --git a/pkg/kn/commands/route/list.go b/pkg/kn/commands/route/list.go
index 7465bf93..8bcb5cdb 100644
--- a/pkg/kn/commands/route/list.go
+++ b/pkg/kn/commands/route/list.go
@@ -22,12 +22,13 @@ import (
 	v1alpha12 "knative.dev/client/pkg/serving/v1alpha1"
 
 	"github.com/spf13/cobra"
+	"knative.dev/client/pkg/kn/commands/flags"
 	"knative.dev/serving/pkg/apis/serving/v1alpha1"
 )
 
 // NewrouteListCommand represents 'kn route list' command
 func NewRouteListCommand(p *commands.KnParams) *cobra.Command {
-	routeListFlags := NewRouteListFlags()
+	routeListFlags := flags.NewListPrintFlags(RouteListHandlers)
 	routeListCommand := &cobra.Command{
 		Use:   "list NAME",
 		Short: "List available routes.",
diff --git a/pkg/kn/commands/route/list_flags.go b/pkg/kn/commands/route/list_flags.go
deleted file mode 100644
index ab8dea94..00000000
--- a/pkg/kn/commands/route/list_flags.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright © 2019 The Knative Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package route
-
-import (
-	"github.com/spf13/cobra"
-	"k8s.io/cli-runtime/pkg/genericclioptions"
-	"knative.dev/client/pkg/kn/commands"
-	hprinters "knative.dev/client/pkg/printers"
-)
-
-// RouteListFlags composes common printer flag structs
-// used in the 'kn route list' command.
-type RouteListFlags struct {
-	GenericPrintFlags  *genericclioptions.PrintFlags
-	HumanReadableFlags *commands.HumanPrintFlags
-}
-
-// AllowedFormats is the list of formats in which data can be displayed
-func (f *RouteListFlags) AllowedFormats() []string {
-	formats := f.GenericPrintFlags.AllowedFormats()
-	formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
-	return formats
-}
-
-// ToPrinter attempts to find a composed set of RouteListFlags suitable for
-// returning a printer based on current flag values.
-func (f *RouteListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
-	// if there are flags specified for generic printing
-	if f.GenericPrintFlags.OutputFlagSpecified() {
-		p, err := f.GenericPrintFlags.ToPrinter()
-		if err != nil {
-			return nil, err
-		}
-		return p, nil
-	}
-	// if no flags specified, use the table printing
-	p, err := f.HumanReadableFlags.ToPrinter(RouteListHandlers)
-	if err != nil {
-		return nil, err
-	}
-	return p, nil
-}
-
-// AddFlags receives a *cobra.Command reference and binds
-// flags related to humanreadable and template printing.
-func (f *RouteListFlags) AddFlags(cmd *cobra.Command) {
-	f.GenericPrintFlags.AddFlags(cmd)
-	f.HumanReadableFlags.AddFlags(cmd)
-}
-
-// NewRouteListFlags returns flags associated with humanreadable,
-// template, and "name" printing, with default values set.
-func NewRouteListFlags() *RouteListFlags {
-	return &RouteListFlags{
-		GenericPrintFlags:  genericclioptions.NewPrintFlags(""),
-		HumanReadableFlags: commands.NewHumanPrintFlags(),
-	}
-}
diff --git a/pkg/kn/commands/service/list.go b/pkg/kn/commands/service/list.go
index 7f7d92fa..9ae2db92 100644
--- a/pkg/kn/commands/service/list.go
+++ b/pkg/kn/commands/service/list.go
@@ -20,13 +20,14 @@ import (
 
 	"github.com/spf13/cobra"
 	"knative.dev/client/pkg/kn/commands"
+	"knative.dev/client/pkg/kn/commands/flags"
 	v1alpha12 "knative.dev/client/pkg/serving/v1alpha1"
 	"knative.dev/serving/pkg/apis/serving/v1alpha1"
 )
 
 // NewServiceListCommand represents 'kn service list' command
 func NewServiceListCommand(p *commands.KnParams) *cobra.Command {
-	serviceListFlags := NewServiceListFlags()
+	serviceListFlags := flags.NewListPrintFlags(ServiceListHandlers)
 
 	serviceListCommand := &cobra.Command{
 		Use:   "list [name]",
diff --git a/pkg/kn/commands/service/list_flags.go b/pkg/kn/commands/service/list_flags.go
deleted file mode 100644
index 1bff01a0..00000000
--- a/pkg/kn/commands/service/list_flags.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright © 2019 The Knative Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package service
-
-import (
-	"github.com/spf13/cobra"
-	"k8s.io/cli-runtime/pkg/genericclioptions"
-	"knative.dev/client/pkg/kn/commands"
-	hprinters "knative.dev/client/pkg/printers"
-)
-
-// ServiceListFlags composes common printer flag structs
-// used in the 'kn service list' command.
-type ServiceListFlags struct {
-	GenericPrintFlags  *genericclioptions.PrintFlags
-	HumanReadableFlags *commands.HumanPrintFlags
-}
-
-// AllowedFormats is the list of formats in which data can be displayed
-func (f *ServiceListFlags) AllowedFormats() []string {
-	formats := f.GenericPrintFlags.AllowedFormats()
-	formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
-	return formats
-}
-
-// ToPrinter attempts to find a composed set of ServiceListFlags suitable for
-// returning a printer based on current flag values.
-func (f *ServiceListFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
-	// if there are flags specified for generic printing
-	if f.GenericPrintFlags.OutputFlagSpecified() {
-		p, err := f.GenericPrintFlags.ToPrinter()
-		if err != nil {
-			return nil, err
-		}
-		return p, nil
-	}
-
-	p, err := f.HumanReadableFlags.ToPrinter(ServiceListHandlers)
-	if err != nil {
-		return nil, err
-	}
-	return p, nil
-}
-
-// AddFlags receives a *cobra.Command reference and binds
-// flags related to humanreadable and template printing.
-func (f *ServiceListFlags) AddFlags(cmd *cobra.Command) {
-	f.GenericPrintFlags.AddFlags(cmd)
-	f.HumanReadableFlags.AddFlags(cmd)
-}
-
-// NewServiceListFlags returns flags associated with humanreadable,
-// template, and "name" printing, with default values set.
-func NewServiceListFlags() *ServiceListFlags {
-	return &ServiceListFlags{
-		GenericPrintFlags:  genericclioptions.NewPrintFlags(""),
-		HumanReadableFlags: commands.NewHumanPrintFlags(),
-	}
-}
-
-// EnsureWithNamespace ensures that humanreadable flags return
-// a printer capable of printing with a "namespace" column.
-func (f *ServiceListFlags) EnsureWithNamespace() {
-	f.HumanReadableFlags.EnsureWithNamespace()
-}
diff --git a/pkg/kn/commands/source/apiserver/list.go b/pkg/kn/commands/source/apiserver/list.go
index 5bdc81c5..dc2ab77b 100644
--- a/pkg/kn/commands/source/apiserver/list.go
+++ b/pkg/kn/commands/source/apiserver/list.go
@@ -24,7 +24,7 @@ import (
 
 // NewAPIServerListCommand is for listing ApiServer source COs
 func NewAPIServerListCommand(p *commands.KnParams) *cobra.Command {
-	listFlags := flags.NewListFlags(APIServerSourceListHandlers)
+	listFlags := flags.NewListPrintFlags(APIServerSourceListHandlers)
 
 	listCommand := &cobra.Command{
 		Use:   "list",
diff --git a/pkg/kn/commands/source/cronjob/list.go b/pkg/kn/commands/source/cronjob/list.go
index d6e0f063..978b1990 100644
--- a/pkg/kn/commands/source/cronjob/list.go
+++ b/pkg/kn/commands/source/cronjob/list.go
@@ -24,7 +24,7 @@ import (
 
 // NewCronJobListCommand is for listing CronJob source COs
 func NewCronJobListCommand(p *commands.KnParams) *cobra.Command {
-	listFlags := flags.NewListFlags(CronJobSourceListHandlers)
+	listFlags := flags.NewListPrintFlags(CronJobSourceListHandlers)
 
 	listCommand := &cobra.Command{
 		Use:   "list",
diff --git a/pkg/kn/commands/source/list_types.go b/pkg/kn/commands/source/list_types.go
index 5a00d7bb..067a7032 100644
--- a/pkg/kn/commands/source/list_types.go
+++ b/pkg/kn/commands/source/list_types.go
@@ -19,11 +19,12 @@ import (
 
 	"github.com/spf13/cobra"
 	"knative.dev/client/pkg/kn/commands"
+	"knative.dev/client/pkg/kn/commands/flags"
 )
 
 // NewListTypesCommand defines and processes `kn source list-types` command operations
 func NewListTypesCommand(p *commands.KnParams) *cobra.Command {
-	listTypesFlags := NewListTypesFlags()
+	listTypesFlags := flags.NewListPrintFlags(ListTypesHandlers)
 	listTypesCommand := &cobra.Command{
 		Use:   "list-types",
 		Short: "List available source types",
diff --git a/pkg/kn/commands/source/list_types_flags.go b/pkg/kn/commands/source/list_types_flags.go
deleted file mode 100644
index 664897ab..00000000
--- a/pkg/kn/commands/source/list_types_flags.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright © 2019 The Knative Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package source
-
-import (
-	"github.com/spf13/cobra"
-	"k8s.io/cli-runtime/pkg/genericclioptions"
-	"knative.dev/client/pkg/kn/commands"
-	hprinters "knative.dev/client/pkg/printers"
-)
-
-// ListTypesFlags composes common printer flag structs
-// used in the 'kn source list-types' command.
-type ListTypesFlags struct {
-	GenericPrintFlags  *genericclioptions.PrintFlags
-	HumanReadableFlags *commands.HumanPrintFlags
-}
-
-// AllowedFormats is the list of formats in which data can be displayed
-func (f *ListTypesFlags) AllowedFormats() []string {
-	formats := f.GenericPrintFlags.AllowedFormats()
-	formats = append(formats, f.HumanReadableFlags.AllowedFormats()...)
-	return formats
-}
-
-// ToPrinter attempts to find a composed set of ListTypesFlags suitable for
-// returning a printer based on current flag values.
-func (f *ListTypesFlags) ToPrinter() (hprinters.ResourcePrinter, error) {
-	// if there are flags specified for generic printing
-	if f.GenericPrintFlags.OutputFlagSpecified() {
-		p, err := f.GenericPrintFlags.ToPrinter()
-		if err != nil {
-			return nil, err
-		}
-		return p, nil
-	}
-
-	p, err := f.HumanReadableFlags.ToPrinter(ListTypesHandlers)
-	if err != nil {
-		return nil, err
-	}
-	return p, nil
-}
-
-// AddFlags receives a *cobra.Command reference and binds
-// flags related to humanreadable and template printing.
-func (f *ListTypesFlags) AddFlags(cmd *cobra.Command) {
-	f.GenericPrintFlags.AddFlags(cmd)
-	f.HumanReadableFlags.AddFlags(cmd)
-}
-
-// NewListTypesFlags returns flags associated with humanreadable,
-// template, and "name" printing, with default values set.
-func NewListTypesFlags() *ListTypesFlags {
-	return &ListTypesFlags{
-		GenericPrintFlags:  genericclioptions.NewPrintFlags(""),
-		HumanReadableFlags: commands.NewHumanPrintFlags(),
-	}
-}
diff --git a/pkg/kn/commands/trigger/list.go b/pkg/kn/commands/trigger/list.go
index 089642a1..fa254365 100644
--- a/pkg/kn/commands/trigger/list.go
+++ b/pkg/kn/commands/trigger/list.go
@@ -25,7 +25,7 @@ import (
 
 // NewTriggerListCommand represents 'kn trigger list' command
 func NewTriggerListCommand(p *commands.KnParams) *cobra.Command {
-	triggerListFlags := flags.NewListFlags(TriggerListHandlers)
+	triggerListFlags := flags.NewListPrintFlags(TriggerListHandlers)
 
 	triggerListCommand := &cobra.Command{
 		Use:   "list [name]",


Test patch:
diff --git a/pkg/kn/commands/flags/list_test.go b/pkg/kn/commands/flags/listprint_test.go
similarity index 88%
rename from pkg/kn/commands/flags/list_test.go
rename to pkg/kn/commands/flags/listprint_test.go
index c1759800..7a9afb0c 100644
--- a/pkg/kn/commands/flags/list_test.go
+++ b/pkg/kn/commands/flags/listprint_test.go
@@ -22,16 +22,16 @@ import (
 	hprinters "knative.dev/client/pkg/printers"
 )
 
-func TestListFlagsFormats(t *testing.T) {
-	flags := NewListFlags(nil)
+func TestListPrintFlagsFormats(t *testing.T) {
+	flags := NewListPrintFlags(nil)
 	formats := flags.AllowedFormats()
 	expected := []string{"json", "yaml", "name", "go-template", "go-template-file", "template", "templatefile", "jsonpath", "jsonpath-file", "no-headers"}
 	assert.DeepEqual(t, formats, expected)
 }
 
-func TestListFlags(t *testing.T) {
+func TestListPrintFlags(t *testing.T) {
 	var cmd *cobra.Command
-	flags := NewListFlags(func(h hprinters.PrintHandler) {})
+	flags := NewListPrintFlags(func(h hprinters.PrintHandler) {})
 
 	cmd = &cobra.Command{}
 	flags.AddFlags(cmd)
diff --git a/pkg/kn/commands/route/list_flags_test.go b/pkg/kn/commands/route/list_flags_test.go
deleted file mode 100644
index d6024a14..00000000
--- a/pkg/kn/commands/route/list_flags_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright © 2019 The Knative Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package route
-
-import (
-	"reflect"
-	"testing"
-
-	"k8s.io/cli-runtime/pkg/genericclioptions"
-	"knative.dev/client/pkg/kn/commands"
-)
-
-func TestRoutListFlags(t *testing.T) {
-	testObject := createMockRouteMeta("foo")
-	knParams := &commands.KnParams{}
-	cmd, _, buf := commands.CreateTestKnCommand(NewRouteCommand(knParams), knParams)
-	routeListFlags := NewRouteListFlags()
-	routeListFlags.AddFlags(cmd)
-	printer, err := routeListFlags.ToPrinter()
-	if genericclioptions.IsNoCompatiblePrinterError(err) {
-		t.Fatalf("Expected to match human readable printer.")
-	}
-	if err != nil {
-		t.Fatalf("Failed to find a proper printer.")
-	}
-	err = printer.PrintObj(testObject, buf)
-	if err != nil {
-		t.Fatalf("Failed to print the object.")
-	}
-	actualFormats := routeListFlags.AllowedFormats()
-	expectedFormats := []string{"json", "yaml", "name", "go-template", "go-template-file", "template", "templatefile", "jsonpath", "jsonpath-file", "no-headers"}
-	if !reflect.DeepEqual(actualFormats, expectedFormats) {
-		t.Fatalf("Expecting allowed formats:\n%s\nFound:\n%s\n", expectedFormats, actualFormats)
-	}
-}
diff --git a/pkg/kn/commands/service/list_flags_test.go b/pkg/kn/commands/service/list_flags_test.go
deleted file mode 100644
index 1a898bce..00000000
--- a/pkg/kn/commands/service/list_flags_test.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright © 2019 The Knative Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package service
-
-import (
-	"reflect"
-	"testing"
-
-	"github.com/spf13/cobra"
-	"gotest.tools/assert"
-)
-
-func TestServiceListFlags(t *testing.T) {
-	var cmd *cobra.Command
-
-	t.Run("verify service list flags", func(t *testing.T) {
-		serviceListFlags := NewServiceListFlags()
-
-		cmd = &cobra.Command{}
-		serviceListFlags.AddFlags(cmd)
-
-		assert.Assert(t, serviceListFlags != nil)
-		assert.Assert(t, cmd.Flags() != nil)
-
-		allowMissingTemplateKeys, err := cmd.Flags().GetBool("allow-missing-template-keys")
-		assert.NilError(t, err)
-		assert.Assert(t, allowMissingTemplateKeys == true)
-
-		actualFormats := serviceListFlags.AllowedFormats()
-		expectedFormats := []string{"json", "yaml", "name", "go-template", "go-template-file", "template", "templatefile", "jsonpath", "jsonpath-file", "no-headers"}
-		assert.Assert(t, reflect.DeepEqual(actualFormats, expectedFormats))
-	})
-}
diff --git a/pkg/kn/commands/source/list_types_flags_test.go b/pkg/kn/commands/source/list_types_flags_test.go
deleted file mode 100644
index f9dc5da5..00000000
--- a/pkg/kn/commands/source/list_types_flags_test.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright © 2019 The Knative Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or im
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package source
-
-import (
-	"testing"
-
-	hprinters "knative.dev/client/pkg/printers"
-
-	"gotest.tools/assert"
-)
-
-func TestListTypesFlagsFormats(t *testing.T) {
-	flags := NewListTypesFlags()
-	formats := flags.AllowedFormats()
-	expected := []string{"json", "yaml", "name", "go-template", "go-template-file", "template", "templatefile", "jsonpath", "jsonpath-file", "no-headers"}
-	assert.DeepEqual(t, formats, expected)
-}
-
-func TestListTypesFlagsPrinter(t *testing.T) {
-	flags := NewListTypesFlags()
-	p, err := flags.GenericPrintFlags.ToPrinter()
-	assert.NilError(t, err)
-	_, ok := p.(hprinters.ResourcePrinter)
-	assert.Check(t, ok == true)
-}