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) {
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)
}
return func(cmd *cobra.Command, args []string) {
f(a, cmd, args)
}
}
func withAppE(f func(*app.App, *cobra.Command, []string) error) func(*cobra.Command, []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 func(cmd *cobra.Command, args []string) error {
return f(a, cmd, args)
}
}