Skip to content

Commit

Permalink
chore: add text type as default format
Browse files Browse the repository at this point in the history
Signed-off-by: Terry Howe <[email protected]>
  • Loading branch information
TerryHowe committed Jun 9, 2024
1 parent ce73b37 commit 8a8027c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmd/oras/internal/option/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var (
Usage: "Get referrers recursively and print in tree format",
}
FormatTypeText = &FormatType{
Name: "",
Name: "text",
Usage: "Print in text format",
}
)
Expand All @@ -87,7 +87,7 @@ func (opts *Format) ApplyFlags(fs *pflag.FlagSet) {
}
_ = w.Flush()
// apply flags
fs.StringVar(&opts.FormatFlag, "format", opts.FormatFlag, buf.String())
fs.StringVar(&opts.FormatFlag, "format", FormatTypeText.Name, buf.String())
fs.StringVar(&opts.Template, "template", "", "[Experimental] Template string used to format output")
}

Expand All @@ -97,7 +97,7 @@ func (opts *Format) Parse(_ *cobra.Command) error {
return err
}

if opts.Type == "" {
if opts.Type == FormatTypeText.Name {
// flag not specified
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/root/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI image layout folder
opts.FlagDescription = "[Preview] attach to an arch-specific subject"
_ = cmd.MarkFlagRequired("artifact-type")
opts.EnableDistributionSpecFlag()
opts.AllowedTypes = []*option.FormatType{option.FormatTypeJSON, option.FormatTypeGoTemplate}
opts.AllowedTypes = []*option.FormatType{option.FormatTypeJSON, option.FormatTypeGoTemplate, option.FormatTypeText}
option.ApplyFlags(&opts, cmd.Flags())
return oerrors.Command(cmd, &opts.Target)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/oras/root/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI image layout
option.FormatTypeTable,
option.FormatTypeJSON.WithUsage("Get direct referrers and output in JSON format"),
option.FormatTypeGoTemplate.WithUsage("Print direct referrers using the given Go template"),
option.FormatTypeText,
}
opts.EnableDistributionSpecFlag()
option.ApplyFlags(&opts, cmd.Flags())
Expand Down
1 change: 1 addition & 0 deletions cmd/oras/root/manifest/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar':
opts.AllowedTypes = []*option.FormatType{
option.FormatTypeJSON.WithUsage("Print in prettified JSON format"),
option.FormatTypeGoTemplate.WithUsage("Print using the given Go template"),
option.FormatTypeText,
}
option.ApplyFlags(&opts, cmd.Flags())
return oerrors.Command(cmd, &opts.Target)
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/root/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar':
cmd.Flags().StringVarP(&opts.Output, "output", "o", ".", "output directory")
cmd.Flags().StringVarP(&opts.ManifestConfigRef, "config", "", "", "output manifest config file")
cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 3, "concurrency level")
opts.AllowedTypes = []*option.FormatType{option.FormatTypeJSON, option.FormatTypeGoTemplate}
opts.AllowedTypes = []*option.FormatType{option.FormatTypeJSON, option.FormatTypeGoTemplate, option.FormatTypeText}
option.ApplyFlags(&opts, cmd.Flags())
return oerrors.Command(cmd, &opts.Target)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/oras/root/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Example - Push file "hi.txt" into an OCI image layout folder 'layout-dir' with t
cmd.Flags().StringVarP(&opts.manifestConfigRef, "config", "", "", "`path` of image config file")
cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type")
cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level")
opts.AllowedTypes = []*option.FormatType{option.FormatTypeJSON, option.FormatTypeGoTemplate}
opts.AllowedTypes = []*option.FormatType{option.FormatTypeJSON, option.FormatTypeGoTemplate, option.FormatTypeText}
option.ApplyFlags(&opts, cmd.Flags())
return oerrors.Command(cmd, &opts.Target)
}
Expand Down

0 comments on commit 8a8027c

Please sign in to comment.