Adds flags to the add subcommand
This commit is contained in:
parent
0a8b3a0e59
commit
527ed8f502
2 changed files with 30 additions and 5 deletions
24
cmd/add.go
24
cmd/add.go
|
@ -2,19 +2,37 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"git.ctrlz.es/mgdelacroix/campaigner/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AddCmd() *cobra.Command {
|
func AddCmd() *cobra.Command {
|
||||||
return &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "add",
|
Use: "add",
|
||||||
Short: "Adds tickets to the campaign",
|
Short: "Adds tickets to the campaign",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: addCmdF,
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
7
model/ticket.go
Normal file
7
model/ticket.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package model
|
||||||
|
|
||||||
|
type Ticket struct {
|
||||||
|
Filename string `json:"filename"`
|
||||||
|
Line int `json:"line"`
|
||||||
|
Text string `json:"text"` // needed??
|
||||||
|
}
|
Loading…
Reference in a new issue