Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/podman/farm/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions docs/source/markdown/podman-farm-list.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ Valid placeholders for the Go template listed below:
| .Name | Farm name |
| .ReadWrite | Indicates if this farm can be modified using the podman farm commands |

[//]: # (BEGIN included file options/noheading.md)
#### **--noheading**, **-n**

Omit the table headings from the listing.

[//]: # (END included file options/noheading.md)

Comment on lines +28 to +34

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is not correct, you need to commit the .in file and options/noheading.md remove the main podman-farm-list.1.md from the git repo and then add it to .gitignore here in the directory.

#### **--quiet**, **-q**

Print farm output in quiet mode. Only print the farm names.
Expand All @@ -38,6 +45,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
Expand Down
10 changes: 10 additions & 0 deletions test/farm/001-farm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down