mirror of https://github.com/containers/podman.git
Fix machine list: --format implies --noheading
It seems like previously if --format was changed then listFlag.noHeading is changed accordingly however printHeader is used to determine whether to print header or not. This patch fixes that problem. Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
This commit is contained in:
parent
15a651f860
commit
f0b9e56e98
|
@ -138,7 +138,7 @@ func outputTemplate(cmd *cobra.Command, responses []*ListReporter) error {
|
||||||
switch {
|
switch {
|
||||||
case cmd.Flags().Changed("format"):
|
case cmd.Flags().Changed("format"):
|
||||||
row = cmd.Flag("format").Value.String()
|
row = cmd.Flag("format").Value.String()
|
||||||
listFlag.noHeading = !report.HasTable(row)
|
printHeader = report.HasTable(row)
|
||||||
row = report.NormalizeFormat(row)
|
row = report.NormalizeFormat(row)
|
||||||
default:
|
default:
|
||||||
row = cmd.Flag("format").Value.String()
|
row = cmd.Flag("format").Value.String()
|
||||||
|
|
|
@ -116,7 +116,7 @@ var _ = Describe("podman machine list", func() {
|
||||||
|
|
||||||
// go format
|
// go format
|
||||||
list := new(listMachine)
|
list := new(listMachine)
|
||||||
listSession, err := mb.setCmd(list.withFormat("{{.Name}}").withNoHeading()).run()
|
listSession, err := mb.setCmd(list.withFormat("{{.Name}}")).run()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(listSession).To(Exit(0))
|
Expect(listSession).To(Exit(0))
|
||||||
Expect(len(listSession.outputToStringSlice())).To(Equal(1))
|
Expect(len(listSession.outputToStringSlice())).To(Equal(1))
|
||||||
|
@ -135,6 +135,15 @@ var _ = Describe("podman machine list", func() {
|
||||||
var listResponse []*machine.ListReporter
|
var listResponse []*machine.ListReporter
|
||||||
err = jsoniter.Unmarshal(listSession.Bytes(), &listResponse)
|
err = jsoniter.Unmarshal(listSession.Bytes(), &listResponse)
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
|
// table format includes the header
|
||||||
|
list = new(listMachine)
|
||||||
|
listSession3, err3 := mb.setCmd(list.withFormat("table {{.Name}}")).run()
|
||||||
|
Expect(err3).NotTo(HaveOccurred())
|
||||||
|
Expect(listSession3).To(Exit(0))
|
||||||
|
listNames3 := listSession3.outputToStringSlice()
|
||||||
|
Expect(len(listNames3)).To(Equal(2))
|
||||||
|
Expect(listNames3).To(ContainSubstring("NAME"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue