Skip to content

Commit

Permalink
reset pretty in handler construction
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
  • Loading branch information
Xiaoxuan Wang committed Oct 10, 2024
1 parent c56fdec commit 49091a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cmd/oras/internal/display/content/manifest_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (h *manifestIndexCreate) OnContentCreated(manifest []byte) error {

// NewManifestIndexCreateHandler creates a new handler.
func NewManifestIndexCreateHandler(out io.Writer, pretty bool, outputPath string) ManifestIndexCreateHandler {
// ignore --pretty when output to a file
if outputPath != "" && outputPath != "-" {
pretty = false
}
return &manifestIndexCreate{
pretty: pretty,
stdout: out,
Expand Down
4 changes: 0 additions & 4 deletions cmd/oras/root/manifest/index/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ Example - Create an index and output the index to stdout, auto push will be disa
opts.RawReference = refs[0]
opts.extraRefs = refs[1:]
opts.sources = args[1:]
// ignore --pretty when output to a file
if opts.outputPath != "" && opts.outputPath != "-" {
opts.Pretty.Pretty = false
}
return option.Parse(cmd, &opts)
},
Aliases: []string{"pack"},
Expand Down
4 changes: 0 additions & 4 deletions cmd/oras/root/manifest/index/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ Example - Update an index and output the index to stdout, auto push will be disa
return err
}
opts.RawReference = args[0]
// ignore --pretty when output to a file
if opts.outputPath != "" && opts.outputPath != "-" {
opts.Pretty.Pretty = false
}
for _, manifestRef := range opts.removeArguments {
if !contentutil.IsDigest(manifestRef) {
return fmt.Errorf("remove: %s is not a digest", manifestRef)
Expand Down

0 comments on commit 49091a2

Please sign in to comment.