feat: wrap commands to send info (#612)

Wrap commands in a better way to pass storage
This commit is contained in:
Henrique Dias authored and GitHub committed 2019-01-07 20:24:23 +00:00
1 parent f396602084
commit 01ff03e426
16 files changed
+170 -212

No files matched your search

+4 -9
View File
@@ -15,18 +15,13 @@ var cmdsAddCmd = &cobra.Command{
Short: "Add a command to run on a specific event",
Long: `Add a command to run on a specific event.`,
Args: cobra.MinimumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {
db := getDB()
defer db.Close()
st := getStorage(db)
s, err := st.Settings.Get()
Run: python(func(cmd *cobra.Command, args []string, d pythonData) {
s, err := d.store.Settings.Get()
checkErr(err)
command := strings.Join(args[1:], " ")
s.Commands[args[0]] = append(s.Commands[args[0]], command)
err = st.Settings.Save(s)
err = d.store.Settings.Save(s)
checkErr(err)
printEvents(s.Commands)
},
}, pythonConfig{}),
}