change: deprecate 'k3d version ls --format' in favor of '--output'

pull/1283/head
iwilltry42 1 year ago
parent f80cd8f374
commit a1c390e7c2
No known key found for this signature in database
GPG Key ID: FD4E78FBAD6B1550
  1. 16
      cmd/root.go

@ -23,6 +23,7 @@ package cmd
import (
"context"
"encoding/json"
"fmt"
"io"
"os"
@ -294,7 +295,8 @@ func NewCmdVersionLs() *cobra.Command {
type Flags struct {
includeRegexp string
excludeRegexp string
format string
format string // deprecated in favor of outputFormat
outputFormat string
sortMode string
limit int
}
@ -315,8 +317,12 @@ func NewCmdVersionLs() *cobra.Command {
}
var format VersionLsOutputFormat
if f, ok := VersionLsOutputFormats[flags.format]; !ok {
l.Log().Fatalf("Unknown output format '%s'", flags.format)
if cmd.Flags().Changed("format") {
l.Log().Warnf("Flag --format is deprecated and will be removed in a future release. Please use --output instead.")
flags.outputFormat = flags.format
}
if f, ok := VersionLsOutputFormats[flags.outputFormat]; !ok {
l.Log().Fatalf("Unknown output format '%s'", flags.outputFormat)
} else {
format = f
}
@ -384,7 +390,9 @@ func NewCmdVersionLs() *cobra.Command {
cmd.Flags().StringVarP(&flags.includeRegexp, "include", "i", ".*", "Include Regexp (default includes everything")
cmd.Flags().StringVarP(&flags.excludeRegexp, "exclude", "e", ".+(rc|engine|alpha|beta|dev|test|arm|arm64|amd64).*", "Exclude Regexp (default excludes pre-releases and arch-specific tags)")
cmd.Flags().StringVarP(&flags.format, "format", "f", string(VersionLsOutputFormatRaw), "Output Format")
cmd.Flags().StringVarP(&flags.format, "format", "f", string(VersionLsOutputFormatRaw), "[DEPRECATED] Use --output instead")
cmd.Flags().StringVarP(&flags.outputFormat, "output", "o", string(VersionLsOutputFormatRaw), "Output Format [raw | repo]")
cmd.MarkFlagsMutuallyExclusive("format", "output")
cmd.Flags().StringVarP(&flags.sortMode, "sort", "s", string(VersionLsSortDesc), "Sort Mode (asc | desc | off)")
cmd.Flags().IntVarP(&flags.limit, "limit", "l", 0, "Limit number of tags in output (0 = unlimited)")

Loading…
Cancel
Save