package cmd import ( "fmt" "github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/cmdHelp" "github.com/spf13/cobra" ) func (c *CmdShow) AttachTemplate(cmd *cobra.Command) *cobra.Command { for range Only.Once { var self = &cobra.Command{ Use: "template", Aliases: []string{}, Annotations: map[string]string{"group": "Template"}, Short: fmt.Sprintf("Template related Sungrow commands."), Long: fmt.Sprintf("Template related Sungrow commands."), DisableFlagParsing: false, DisableFlagsInUseLine: false, PreRunE: cmds.SunGrowArgs, RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, Args: cobra.MinimumNArgs(1), } cmd.AddCommand(self) self.Example = cmdHelp.PrintExamples(self, "") c.AttachTemplateList(self) c.AttachTemplatePoints(self) c.AttachTemplateData(self) c.AttachTemplateGraph(self) c.AttachTemplateSave(self) } return c.SelfCmd } func (c *CmdShow) AttachTemplateList(cmd *cobra.Command) *cobra.Command { var self = &cobra.Command{ Use: "list", Aliases: []string{"ls"}, Annotations: map[string]string{"group": "Template"}, Short: fmt.Sprintf("Get all defined templates."), Long: fmt.Sprintf("Get all defined templates."), DisableFlagParsing: false, DisableFlagsInUseLine: false, PreRunE: cmds.SunGrowArgs, RunE: c.funcTemplateList, Args: cobra.ExactArgs(0), } cmd.AddCommand(self) self.Example = cmdHelp.PrintExamples(self, "") return cmd } func (c *CmdShow) funcTemplateList(_ *cobra.Command, _ []string) error { for range Only.Once { cmds.Api.SunGrow.OutputType.SetTable() c.Error = cmds.Api.SunGrow.TemplateList() } return c.Error } func (c *CmdShow) AttachTemplatePoints(cmd *cobra.Command) *cobra.Command { var self = &cobra.Command{ Use: "points