Skip to content

Commit

Permalink
Merge pull request #162 from markylaing/format-flag
Browse files Browse the repository at this point in the history
Adds a format flag when listing tokens and cluster members.
  • Loading branch information
tomponline authored Sep 18, 2023
2 parents fea03ad + 35a0900 commit f475486
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions microcloud/cmd/microcloud/cluster_members.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func (c *cmdClusterMembers) Run(cmd *cobra.Command, args []string) error {
}

type cmdClusterMembersList struct {
common *CmdControl
common *CmdControl
flagFormat string
}

func (c *cmdClusterMembersList) Command() *cobra.Command {
Expand All @@ -46,6 +47,8 @@ func (c *cmdClusterMembersList) Command() *cobra.Command {
RunE: c.Run,
}

cmd.Flags().StringVarP(&c.flagFormat, "format", "f", cli.TableFormatTable, "Format (csv|json|table|yaml|compact)")

return cmd
}

Expand Down Expand Up @@ -94,7 +97,7 @@ func (c *cmdClusterMembersList) Run(cmd *cobra.Command, args []string) error {
header := []string{"NAME", "ADDRESS", "ROLE", "FINGERPRINT", "STATUS"}
sort.Sort(cli.SortColumnsNaturally(data))

return cli.RenderTable(cli.TableFormatTable, header, data, clusterMembers)
return cli.RenderTable(c.flagFormat, header, data, clusterMembers)
}

type cmdClusterMemberRemove struct {
Expand Down
7 changes: 5 additions & 2 deletions microcloud/cmd/microcloud/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ func (c *cmdTokensAdd) Run(cmd *cobra.Command, args []string) error {
}

type cmdTokensList struct {
common *CmdControl
common *CmdControl
flagFormat string
}

func (c *cmdTokensList) Command() *cobra.Command {
Expand All @@ -83,6 +84,8 @@ func (c *cmdTokensList) Command() *cobra.Command {
RunE: c.Run,
}

cmd.Flags().StringVarP(&c.flagFormat, "format", "f", cli.TableFormatTable, "Format (csv|json|table|yaml|compact)")

return cmd
}

Expand Down Expand Up @@ -110,7 +113,7 @@ func (c *cmdTokensList) Run(cmd *cobra.Command, args []string) error {
header := []string{"NAME", "TOKENS"}
sort.Sort(cli.SortColumnsNaturally(data))

return cli.RenderTable(cli.TableFormatTable, header, data, records)
return cli.RenderTable(c.flagFormat, header, data, records)
}

type cmdTokensRevoke struct {
Expand Down

0 comments on commit f475486

Please sign in to comment.