Skip to content

Commit

Permalink
feat(pkg/cmd): delete subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
leodido authored and fntlnz committed Nov 25, 2018
1 parent e276eac commit a4dab2a
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions pkg/cmd/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cmd

import (
"fmt"

"github.com/davecgh/go-spew/spew"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
// "k8s.io/kubernetes/pkg/kubectl/util/templates"
)

var (
deleteShort = `Delete a bpftrace program execution` // Wrap with i18n.T()
deleteLong = `
...`

deleteExamples = `
# Delete a specific bpftrace program
%[1]s trace delete k656ee75a-ee3c-11e8-9e7a-8c164500a77e
# Delete all bpftrace programs in a specific namespace
%[1]s trace delete -n myns"`
)

// DeleteOptions ...
type DeleteOptions struct {
genericclioptions.IOStreams
}

// NewDeleteOptions provides an instance of DeleteOptions with default values.
func NewDeleteOptions(streams genericclioptions.IOStreams) *DeleteOptions {
return &DeleteOptions{
IOStreams: streams,
}
}

// NewDeleteCommand provides the delete command wrapping DeleteOptions.
func NewDeleteCommand(streams genericclioptions.IOStreams) *cobra.Command {
o := NewDeleteOptions(streams)

cmd := &cobra.Command{
Use: "delete TRACE_ID",
Short: deleteShort,
Long: deleteLong, // Wrap with templates.LongDesc()
Example: fmt.Sprintf(deleteExamples, "kubectl"), // Wrap with templates.Examples()
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("delete")
spew.Dump(o)
},
}

return cmd
}

0 comments on commit a4dab2a

Please sign in to comment.