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/podman-farm-list.1.md b/docs/source/markdown/podman-farm-list.1.md index ed4ba82250..3994c25542 100644 --- a/docs/source/markdown/podman-farm-list.1.md +++ b/docs/source/markdown/podman-farm-list.1.md @@ -29,6 +29,10 @@ Valid placeholders for the Go template listed below: Print farm output in quiet mode. Only print the farm names. +@@option noheading + +Print farm output without the headers + ## EXAMPLE List all farms: @@ -38,6 +42,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 ad918998d3..a29a23b450 100644 --- a/test/farm/001-farm.bats +++ b/test/farm/001-farm.bats @@ -9,6 +9,16 @@ load helpers.bash run_podman farm ls assert "$output" =~ $FARMNAME assert "$output" =~ "test-node" + + #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" {