From 7b1b61a582ce389943d2f88e81f19e18dd2b8aed Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Thu, 24 Sep 2020 13:34:25 +0200 Subject: [PATCH] Add --campaign persistent flag --- cmd/root.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index fb880a9..d339238 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -11,7 +11,9 @@ 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") + campaignPath, _ := cmd.Flags().GetString("campaign") + + a, err := app.NewApp(campaignPath) if err != nil { fmt.Fprintln(os.Stderr, "ERROR: "+err.Error()) os.Exit(1) @@ -39,6 +41,8 @@ func RootCmd() *cobra.Command { Short: "Create and manage Open Source campaigns", } + cmd.PersistentFlags().String("campaign", "campaign.json", "the path to the campaign file") + cmd.AddCommand( AddCmd(), // FilterCmd(),