Skip to content

Commit

Permalink
feat(pkg/cmd): attach 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 0332ceb commit 108fe85
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pkg/cmd/attach.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 (
attachShort = `` // Wrap with i18n.T()
attachLong = attachShort + `
...`

attachExamples = `
# ...
%[1]s trace attach -h
# ...
%[1]s trace (...) attach`
)

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

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

// NewAttachCommand provides the attach command wrapping AttachOptions.
func NewAttachCommand(streams genericclioptions.IOStreams) *cobra.Command {
o := NewAttachOptions(streams)

cmd := &cobra.Command{
Use: "attach TRACE_ID",
DisableFlagsInUseLine: true,
Short: attachShort,
Long: attachLong, // Wrap with templates.LongDesc()
Example: fmt.Sprintf(attachExamples, "kubectl"), // Wrap with templates.Examples()
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("attach")
spew.Dump(o)
},
}

return cmd
}

0 comments on commit 108fe85

Please sign in to comment.