From 4d9cf723fd1098c94d0ba039e14271fd5336c27a Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Wed, 26 Feb 2025 20:15:33 +0100 Subject: [PATCH] main: rename `output` to `format` We had a chat about this and we feel that `format` is less ambiguous a name for this argument. Signed-off-by: Simon de Vlieger --- README.md | 6 +++--- cmd/image-builder/main.go | 6 +++--- cmd/image-builder/main_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 563134b..6e4c59a 100644 --- a/README.md +++ b/README.md @@ -157,11 +157,11 @@ The following filters are currently supported, shell-style globbing is supported * type: the image type name (e.g. qcow2) * bootmode: the bootmode (legacy, UEFI, hybrid) -### Output control +### Text control -The output can also be switched, supported are "text", "json": +The text format can also be switched, supported are "text", "json": ```console -$ image-builder list-images --output=json +$ image-builder list-images --format=json [ { "distro": { diff --git a/cmd/image-builder/main.go b/cmd/image-builder/main.go index c53f420..19e8f9b 100644 --- a/cmd/image-builder/main.go +++ b/cmd/image-builder/main.go @@ -37,7 +37,7 @@ func cmdListImages(cmd *cobra.Command, args []string) error { if err != nil { return err } - output, err := cmd.Flags().GetString("output") + format, err := cmd.Flags().GetString("format") if err != nil { return err } @@ -50,7 +50,7 @@ func cmdListImages(cmd *cobra.Command, args []string) error { return err } - return listImages(dataDir, extraRepos, output, filter) + return listImages(dataDir, extraRepos, format, filter) } func ostreeImageOptions(cmd *cobra.Command) (*ostree.ImageOptions, error) { @@ -343,7 +343,7 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support. Args: cobra.NoArgs, } listImagesCmd.Flags().StringArray("filter", nil, `Filter distributions by a specific criteria (e.g. "type:iot*")`) - listImagesCmd.Flags().String("output", "", "Output in a specific format (text, json)") + listImagesCmd.Flags().String("format", "", "Output in a specific format (text, json)") rootCmd.AddCommand(listImagesCmd) manifestCmd := &cobra.Command{ diff --git a/cmd/image-builder/main_test.go b/cmd/image-builder/main_test.go index d5d8f07..aa00a62 100644 --- a/cmd/image-builder/main_test.go +++ b/cmd/image-builder/main_test.go @@ -34,7 +34,7 @@ func TestListImagesNoArguments(t *testing.T) { restore := main.MockNewRepoRegistry(testrepos.New) defer restore() - for _, args := range [][]string{nil, []string{"--output=text"}} { + for _, args := range [][]string{nil, []string{"--format=text"}} { restore = main.MockOsArgs(append([]string{"list-images"}, args...)) defer restore() @@ -55,7 +55,7 @@ func TestListImagesNoArgsOutputJSON(t *testing.T) { restore := main.MockNewRepoRegistry(testrepos.New) defer restore() - restore = main.MockOsArgs([]string{"list-images", "--output=json"}) + restore = main.MockOsArgs([]string{"list-images", "--format=json"}) defer restore() var fakeStdout bytes.Buffer