Skip to content

Commit a4dab2a

Browse files
leodidofntlnz
authored andcommitted
feat(pkg/cmd): delete subcommand
1 parent e276eac commit a4dab2a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

pkg/cmd/delete.go

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/davecgh/go-spew/spew"
7+
"github.com/spf13/cobra"
8+
"k8s.io/cli-runtime/pkg/genericclioptions"
9+
// "k8s.io/kubernetes/pkg/kubectl/util/templates"
10+
)
11+
12+
var (
13+
deleteShort = `Delete a bpftrace program execution` // Wrap with i18n.T()
14+
deleteLong = `
15+
...`
16+
17+
deleteExamples = `
18+
# Delete a specific bpftrace program
19+
%[1]s trace delete k656ee75a-ee3c-11e8-9e7a-8c164500a77e
20+
21+
# Delete all bpftrace programs in a specific namespace
22+
%[1]s trace delete -n myns"`
23+
)
24+
25+
// DeleteOptions ...
26+
type DeleteOptions struct {
27+
genericclioptions.IOStreams
28+
}
29+
30+
// NewDeleteOptions provides an instance of DeleteOptions with default values.
31+
func NewDeleteOptions(streams genericclioptions.IOStreams) *DeleteOptions {
32+
return &DeleteOptions{
33+
IOStreams: streams,
34+
}
35+
}
36+
37+
// NewDeleteCommand provides the delete command wrapping DeleteOptions.
38+
func NewDeleteCommand(streams genericclioptions.IOStreams) *cobra.Command {
39+
o := NewDeleteOptions(streams)
40+
41+
cmd := &cobra.Command{
42+
Use: "delete TRACE_ID",
43+
Short: deleteShort,
44+
Long: deleteLong, // Wrap with templates.LongDesc()
45+
Example: fmt.Sprintf(deleteExamples, "kubectl"), // Wrap with templates.Examples()
46+
Run: func(cmd *cobra.Command, args []string) {
47+
fmt.Println("delete")
48+
spew.Dump(o)
49+
},
50+
}
51+
52+
return cmd
53+
}

0 commit comments

Comments
 (0)