Defer campaign loading in the wrappers

This commit is contained in:
Miguel de la Cruz 2020-04-30 16:54:04 +02:00
parent 2f6d27d831
commit a40693b493

View file

@ -10,25 +10,25 @@ import (
) )
func withApp(f func(*app.App, *cobra.Command, []string)) func(*cobra.Command, []string) { func withApp(f func(*app.App, *cobra.Command, []string)) func(*cobra.Command, []string) {
a, err := app.NewApp("./campaign.json")
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR: "+err.Error())
os.Exit(1)
}
return func(cmd *cobra.Command, args []string) { return func(cmd *cobra.Command, args []string) {
a, err := app.NewApp("./campaign.json")
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR: "+err.Error())
os.Exit(1)
}
f(a, cmd, args) f(a, cmd, args)
} }
} }
func withAppE(f func(*app.App, *cobra.Command, []string) error) func(*cobra.Command, []string) error { func withAppE(f func(*app.App, *cobra.Command, []string) error) func(*cobra.Command, []string) error {
a, err := app.NewApp("./campaign.json")
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR: "+err.Error())
os.Exit(1)
}
return func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error {
a, err := app.NewApp("./campaign.json")
if err != nil {
fmt.Fprintln(os.Stderr, "ERROR: "+err.Error())
os.Exit(1)
}
return f(a, cmd, args) return f(a, cmd, args)
} }
} }