diff --git a/cmd/podman/farm/list.go b/cmd/podman/farm/list.go index 480181c972..38c4748b93 100644 --- a/cmd/podman/farm/list.go +++ b/cmd/podman/farm/list.go @@ -51,13 +51,14 @@ func init() { _ = lsCommand.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteFormat(&config.Farm{})) flags.BoolVarP(&lsOpts.Quiet, "quiet", "q", false, "Print farm names only") + flags.BoolP("noheading", "n", false, "Do not print headers") } func list(cmd *cobra.Command, args []string) error { if lsOpts.Quiet && cmd.Flag("format").Changed { return errors.New("quiet and format flags cannot be used together") } - + noHeading, _ := cmd.Flags().GetBool("noheading") format := lsOpts.Format if format == "" && len(args) > 0 { format = "json" @@ -96,7 +97,7 @@ func list(cmd *cobra.Command, args []string) error { return err } - if rpt.RenderHeaders { + if rpt.RenderHeaders && !noHeading { err = rpt.Execute([]map[string]string{{ "Default": "Default", "Connections": "Connections", diff --git a/docs/source/markdown/.gitignore b/docs/source/markdown/.gitignore index 4e72cb04a8..8f58e99d5f 100644 --- a/docs/source/markdown/.gitignore +++ b/docs/source/markdown/.gitignore @@ -14,6 +14,7 @@ podman-create.1.md podman-diff.1.md podman-exec.1.md podman-farm-build.1.md +podman-farm-list.1.md podman-image-sign.1.md podman-image-trust.1.md podman-images.1.md diff --git a/docs/source/markdown/options/noheading.md b/docs/source/markdown/options/noheading.md index 6fd17d11aa..4282246235 100644 --- a/docs/source/markdown/options/noheading.md +++ b/docs/source/markdown/options/noheading.md @@ -1,5 +1,5 @@ ####> This option file is used in: -####> podman artifact ls, image trust, images, machine list, network ls, pod ps, quadlet list, secret ls, volume ls +####> podman artifact ls, farm list, image trust, images, machine list, network ls, pod ps, quadlet list, secret ls, volume ls ####> If file is edited, make sure the changes ####> are applicable to all of those. #### **--noheading**, **-n** diff --git a/docs/source/markdown/podman-farm-list.1.md b/docs/source/markdown/podman-farm-list.1.md.in similarity index 91% rename from docs/source/markdown/podman-farm-list.1.md rename to docs/source/markdown/podman-farm-list.1.md.in index ed4ba82250..2ba0e79a14 100644 --- a/docs/source/markdown/podman-farm-list.1.md +++ b/docs/source/markdown/podman-farm-list.1.md.in @@ -25,6 +25,8 @@ Valid placeholders for the Go template listed below: | .Name | Farm name | | .ReadWrite | Indicates if this farm can be modified using the podman farm commands | +@@option noheading + #### **--quiet**, **-q** Print farm output in quiet mode. Only print the farm names. @@ -38,6 +40,14 @@ Name Connections Default ReadWrite farm1 [f38 f37] false true farm2 [f37] true true ``` + +List all farms without showing the headers: +``` +$ podman farm list --noheading +farm1 [f38 f37] false true +farm2 [f37] true true +``` + Show farms in JSON format: ``` $ podman farm list --format json diff --git a/test/farm/001-farm.bats b/test/farm/001-farm.bats index 27d71a5ac4..ff060ad51d 100644 --- a/test/farm/001-farm.bats +++ b/test/farm/001-farm.bats @@ -9,6 +9,19 @@ load helpers.bash run_podman farm ls assert "$output" =~ $FARMNAME assert "$output" =~ ${CONNECTION_NAME} + + #Confirm name header present on farm list output + assert "$output" =~ "Name" + + #Test the farm list output for no headers + run_podman farm ls --noheading + assert "$output" !~ "Name" + assert "$output" =~ "$FARMNAME" + + #Test the farm list noheading shorthand + run_podman farm ls -n + assert "$output" !~ "Name" + assert "$output" =~ "$FARMNAME" } @test "farm - build on local only" {