2020-02-29 00:49:55 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2020-02-29 13:33:03 +01:00
|
|
|
"git.ctrlz.es/mgdelacroix/campaigner/campaign"
|
|
|
|
"git.ctrlz.es/mgdelacroix/campaigner/model"
|
|
|
|
|
2020-02-29 00:49:55 +01:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func InitCmd() *cobra.Command {
|
2020-02-29 13:33:03 +01:00
|
|
|
cmd := &cobra.Command{
|
2020-02-29 00:49:55 +01:00
|
|
|
Use: "init",
|
|
|
|
Short: "Creates a new campaign in the current directory",
|
|
|
|
Args: cobra.NoArgs,
|
2020-02-29 13:33:03 +01:00
|
|
|
Run: initCmdF,
|
2020-02-29 00:49:55 +01:00
|
|
|
}
|
|
|
|
|
2020-02-29 13:33:03 +01:00
|
|
|
cmd.Flags().StringP("epic", "e", "", "the epic id to associate this campaign with")
|
|
|
|
cmd.MarkFlagRequired("epic")
|
|
|
|
|
|
|
|
return cmd
|
2020-02-29 00:49:55 +01:00
|
|
|
}
|
|
|
|
|
2020-02-29 13:33:03 +01:00
|
|
|
func initCmdF(cmd *cobra.Command, _ []string) {
|
|
|
|
epic, _ := cmd.Flags().GetString("epic")
|
|
|
|
if err := campaign.Save(&model.Campaign{Epic: epic}); err != nil {
|
|
|
|
ErrorAndExit(cmd, err)
|
|
|
|
}
|
2020-02-29 00:49:55 +01:00
|
|
|
}
|