MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / ExportCommands

Function ExportCommands

core/utils/csv/command.go:15–43  ·  view source on GitHub ↗
(filename string, commands []CommandTemplate)

Source from the content-addressed store, hash-verified

13}
14
15func ExportCommands(filename string, commands []CommandTemplate) error {
16 file, err := os.Create(filename)
17 if err != nil {
18 return err
19 }
20 defer file.Close()
21
22 writer := csv.NewWriter(file)
23 defer writer.Flush()
24
25 if err := writer.Write([]string{
26 i18n.GetMsgByKey("Name"),
27 i18n.GetMsgByKey("Command"),
28 }); err != nil {
29 return err
30 }
31
32 for _, log := range commands {
33 record := []string{
34 log.Name,
35 log.Command,
36 }
37 if err := writer.Write(record); err != nil {
38 return err
39 }
40 }
41
42 return nil
43}

Callers

nothing calls this directly

Calls 4

WriteMethod · 0.95
CreateMethod · 0.65
CloseMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected