-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |