func NewDeleteCommand(factory cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
	o := NewDeleteOptions(streams)
	cmd := &cobra.Command{
		Use:     "delete (TRACE_ID | TRACE_NAME)",
		Short:   deleteShort,
		Long:    deleteLong,                              
		Example: fmt.Sprintf(deleteExamples, "kubectl"),  
		PreRunE: func(c *cobra.Command, args []string) error {
			return o.Validate(c, args)
		},
		RunE: func(c *cobra.Command, args []string) error {
			if err := o.Complete(factory, c, args); err != nil {
				return err
			}
			if err := o.Run(); err != nil {
				fmt.Fprintln(o.ErrOut, err.Error())
				return nil
			}
			return nil
		},
	}
	o.ResourceBuilderFlags.AddFlags(cmd.Flags())
	return cmd
}
NewDeleteCommand provides the delete command wrapping DeleteOptions.
package cmd
import (
	"fmt"
	"github.com/iovisor/kubectl-trace/pkg/meta"
	"github.com/iovisor/kubectl-trace/pkg/tracejob"
	"github.com/spf13/cobra"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/cli-runtime/pkg/genericclioptions"
	batchv1client "k8s.io/client-go/kubernetes/typed/batch/v1"
	corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
	"k8s.io/client-go/rest"
	cmdutil "k8s.io/kubectl/pkg/cmd/util"
)
var (
	deleteShort = `Delete a bpftrace program execution`  
	deleteLong  = deleteShort
	deleteExamples = `
  # Delete a specific bpftrace program by ID
  %[1]s trace delete k656ee75a-ee3c-11e8-9e7a-8c164500a77e
  # Delete a specific bpftrace program by name
  %[1]s trace delete kubectl-trace-1bb3ae39-efe8-11e8-9f29-8c164500a77e
  # Delete all bpftrace programs in a specific namespace
  %[1]s trace delete -n myns --all
  # Delete all bpftrace programs in all the namespaces
  %[1]s trace delete --all-namespaces`
)
type DeleteOptions struct {
	genericclioptions.IOStreams
	ResourceBuilderFlags *genericclioptions.ResourceBuilderFlags
	traceID              *types.UID
	traceName            *string
	namespace            string
	clientConfig         *rest.Config
	all                  bool
	allNamespaces        bool
}
func NewDeleteOptions(streams genericclioptions.IOStreams) *DeleteOptions {
	rbFlags := &genericclioptions.ResourceBuilderFlags{}
	rbFlags.WithAllNamespaces(false)
	rbFlags.WithAll(false)
	return &DeleteOptions{
		ResourceBuilderFlags: rbFlags,
		IOStreams:            streams,
		all:                  false,
	}
}