diff --git a/cmd/oras/internal/display/metadata/interface.go b/cmd/oras/internal/display/metadata/interface.go index 18707111b..fc4f7b419 100644 --- a/cmd/oras/internal/display/metadata/interface.go +++ b/cmd/oras/internal/display/metadata/interface.go @@ -16,28 +16,22 @@ limitations under the License. package metadata import ( - "io" - ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "oras.land/oras/cmd/oras/internal/display/metadata/view" "oras.land/oras/cmd/oras/internal/option" ) -type Outputable interface { - // WithOutput resets output of the handler. - WithOutput(out io.Writer) -} - // PushHandler handles metadata output for push events. type PushHandler interface { OnCopied(opts *option.Target) error OnCompleted(root ocispec.Descriptor) error - Outputable + view.Outputable } // AttachHandler handles metadata output for attach events. type AttachHandler interface { OnCompleted(opts *option.Target, root, subject ocispec.Descriptor) error - Outputable + view.Outputable } // PullHandler handles metadata output for attach events. @@ -46,5 +40,5 @@ type PullHandler interface { OnFilePulled(name string, outputDir string, desc ocispec.Descriptor, descPath string) // OnCompleted is called when the pull cmd execution is completed. OnCompleted(opts *option.Target, desc ocispec.Descriptor, layerSkipped bool) error - Outputable + view.Outputable } diff --git a/cmd/oras/internal/display/metadata/view/printer.go b/cmd/oras/internal/display/metadata/view/printer.go index d117d1e97..2b368b12c 100644 --- a/cmd/oras/internal/display/metadata/view/printer.go +++ b/cmd/oras/internal/display/metadata/view/printer.go @@ -22,16 +22,21 @@ import ( "io" "github.com/Masterminds/sprig/v3" - "oras.land/oras/cmd/oras/internal/display/metadata" ) +// Outputable interface is used to reset output of the handler. +type Outputable interface { + // WithOutput resets output of the handler. + WithOutput(out io.Writer) +} + // Printer prints. type Printer interface { Printf(format string, a ...any) (n int, err error) Println(a ...any) (n int, err error) PrintJSON(object any) error ParseAndWrite(object any, templateStr string) error - metadata.Outputable + Outputable } type printer struct {