mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-11-03 07:08:53 +00:00
35 lines
848 B
Go
35 lines
848 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/spf13/cobra"
|
|
"github.com/up9inc/mizu/cli/mizu"
|
|
"github.com/up9inc/mizu/cli/uiUtils"
|
|
"io/ioutil"
|
|
)
|
|
|
|
var outputFileName string
|
|
|
|
var configCmd = &cobra.Command{
|
|
Use: "config",
|
|
Short: "Generate example config file to stdout",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
template := mizu.GetTemplateConfig()
|
|
if outputFileName != "" {
|
|
data := []byte(template)
|
|
_ = ioutil.WriteFile(outputFileName, data, 0644)
|
|
mizu.Log.Infof(fmt.Sprintf("Template File written to %s", fmt.Sprintf(uiUtils.Purple, outputFileName)))
|
|
} else {
|
|
mizu.Log.Debugf("Writing template config.\n%v", template)
|
|
fmt.Printf("%v", template)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(configCmd)
|
|
|
|
configCmd.Flags().StringVarP(&outputFileName, "file", "f", "", "Save content to local file")
|
|
}
|