main: rename list-images to list

Rename the `list-images` command to `list`. We don't have `-image(s)` in
our other subcommands so this is for consistency.

We keep a `list-images` alias behind for compatibility reasons.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-03-31 11:57:27 +02:00 committed by Michael Vogt
parent a963712152
commit 274a75387b
5 changed files with 27 additions and 26 deletions

View file

@ -42,7 +42,7 @@ func getOneImage(distroName, imgTypeStr, archStr string, repoOpts *repoOptions)
return nil, err
}
// strip prefixes to make ib copy/paste friendly when pasting output
// from "list-images"
// from "list"
distroName = strings.TrimPrefix(distroName, "distro:")
imgTypeStr = strings.TrimPrefix(imgTypeStr, "type:")
archStr = strings.TrimPrefix(archStr, "arch:")

View file

@ -392,16 +392,17 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
rootCmd.SetOut(osStdout)
rootCmd.SetErr(osStderr)
listImagesCmd := &cobra.Command{
Use: "list-images",
listCmd := &cobra.Command{
Use: "list",
Short: "List buildable images, use --filter to limit further",
RunE: cmdListImages,
SilenceUsage: true,
Args: cobra.NoArgs,
Aliases: []string{"list-images"},
}
listImagesCmd.Flags().StringArray("filter", nil, `Filter distributions by a specific criteria (e.g. "type:iot*")`)
listImagesCmd.Flags().String("format", "", "Output in a specific format (text, json)")
rootCmd.AddCommand(listImagesCmd)
listCmd.Flags().StringArray("filter", nil, `Filter distributions by a specific criteria (e.g. "type:iot*")`)
listCmd.Flags().String("format", "", "Output in a specific format (text, json)")
rootCmd.AddCommand(listCmd)
manifestCmd := &cobra.Command{
Use: "manifest <image-type>",

View file

@ -35,7 +35,7 @@ func TestListImagesNoArguments(t *testing.T) {
defer restore()
for _, args := range [][]string{nil, []string{"--format=text"}} {
restore = main.MockOsArgs(append([]string{"list-images"}, args...))
restore = main.MockOsArgs(append([]string{"list"}, args...))
defer restore()
var fakeStdout bytes.Buffer
@ -55,7 +55,7 @@ func TestListImagesNoArgsOutputJSON(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New)
defer restore()
restore = main.MockOsArgs([]string{"list-images", "--format=json"})
restore = main.MockOsArgs([]string{"list", "--format=json"})
defer restore()
var fakeStdout bytes.Buffer
@ -80,7 +80,7 @@ func TestListImagesFilteringSmoke(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New)
defer restore()
restore = main.MockOsArgs([]string{"list-images", "--filter=centos*"})
restore = main.MockOsArgs([]string{"list", "--filter=centos*"})
defer restore()
var fakeStdout bytes.Buffer
@ -113,7 +113,7 @@ func TestListImagesErrorsOnExtraArgs(t *testing.T) {
restore := main.MockNewRepoRegistry(testrepos.New)
defer restore()
restore = main.MockOsArgs(append([]string{"list-images"}, "extra-arg"))
restore = main.MockOsArgs(append([]string{"list"}, "extra-arg"))
defer restore()
var fakeStdout bytes.Buffer
@ -121,7 +121,7 @@ func TestListImagesErrorsOnExtraArgs(t *testing.T) {
defer restore()
err := main.Run()
assert.EqualError(t, err, `unknown command "extra-arg" for "image-builder list-images"`)
assert.EqualError(t, err, `unknown command "extra-arg" for "image-builder list"`)
}
func hasDepsolveDnf() bool {