diff --git a/cmd/add.go b/cmd/add.go index c1f43f5..4cbf311 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -2,19 +2,37 @@ package cmd import ( "github.com/spf13/cobra" + + "git.ctrlz.es/mgdelacroix/campaigner/model" ) func AddCmd() *cobra.Command { - return &cobra.Command{ + cmd := &cobra.Command{ Use: "add", Short: "Adds tickets to the campaign", - Args: cobra.NoArgs, - RunE: addCmdF, + Args: cobra.NoArgs, + RunE: addCmdF, } - // add flags and examples + cmd.Flags().StringP("dir", "d", "", "directory containing the source code") + _ = cmd.MarkFlagRequired("dir") + cmd.Flags().StringSliceP("grep", "g", []string{}, "runs a grep command to generate the tickets") + cmd.Flags().BoolP("case-insensitive", "i", false, "makes the search case insensitive") + // cmd.Flags().StringP("govet", "v", "", "runs a govet command to generate the tickets") + // govet bin path? + + return cmd } -func addCmdF(_ *cobra.Command, _ []string) error { +func RunGrep(dir string, strs []string, caseInsensitive bool) ([]model.Ticket, error) { + // grep -nrI TEXT . + // -i as well with case insensitive + + return nil, nil +} + +func addCmdF(cmd *cobra.Command, _ []string) error { + // either govet or grep + return nil } diff --git a/model/ticket.go b/model/ticket.go new file mode 100644 index 0000000..06c32b5 --- /dev/null +++ b/model/ticket.go @@ -0,0 +1,7 @@ +package model + +type Ticket struct { + Filename string `json:"filename"` + Line int `json:"line"` + Text string `json:"text"` // needed?? +}