Skip to content

Commit

Permalink
Update the Long description for incus/network/forward/list to include…
Browse files Browse the repository at this point in the history
… --column flag

Signed-off-by: HassanAlsamahi <hassanalsamahi12@gmail.com>
  • Loading branch information
HassanAlsamahi committed Aug 13, 2024
1 parent aeb5d59 commit 62ba99f
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions cmd/incus/network_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,40 @@ type cmdNetworkForwardList struct {
global *cmdGlobal
networkForward *cmdNetworkForward

flagFormat string
flagFormat string
flagColumns string
}

func (c *cmdNetworkForwardList) Command() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = usage("list", i18n.G("[<remote>:]<network>"))
cmd.Aliases = []string{"ls"}
cmd.Short = i18n.G("List available network forwards")
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G("List available network forwards"))
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
`List available network forwards
Default column layout: ldDp
== Columns ==
The -c option takes a comma separated list of arguments that control
which instance attributes to output when displaying in table or csv
format.
Column arguments are either pre-defined shorthand chars (see below),
or (extended) config keys.
Commas between consecutive shorthand chars are optional.
Pre-defined column shorthand chars:
l - Listen Address
d - Description
D - Default Target Address
p - Port
L - Location of the network zone (e.g. its cluster member)`))

cmd.RunE = c.Run
cmd.Flags().StringVarP(&c.flagFormat, "format", "f", "table", i18n.G("Format (csv|json|table|yaml|compact)")+"``")
cmd.Flags().StringVarP(&c.flagColumns, "columns", "c", defaultNetworkForwardColumns, i18n.G("Columns")+"``")

cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 0 {
Expand All @@ -98,6 +120,8 @@ func (c *cmdNetworkForwardList) Command() *cobra.Command {
return cmd
}

const defaultNetworkForwardColumns = "ldDp"

func (c *cmdNetworkForwardList) Run(cmd *cobra.Command, args []string) error {
// Quick checks.
exit, err := c.global.CheckArgs(cmd, args, 1, 1)
Expand Down

0 comments on commit 62ba99f

Please sign in to comment.