fix flag access (#1506)

This commit is contained in:
Zachary Rice authored and GitHub committed 2024-09-14 04:01:27 -05:00
1 parent 44ad62e0b1
commit 9463ffaa5e
6 files changed
+35 -33

No files matched your search

+11 -5
View File
@@ -25,12 +25,22 @@ var gitCmd = &cobra.Command{
}
func runGit(cmd *cobra.Command, args []string) {
initConfig()
var (
findings []report.Finding
err error
)
// grab source
source := "."
if len(args) == 1 {
source = args[0]
if source == "" {
source = "."
}
}
initConfig(source)
// setup config (aka, the thing that defines rules)
cfg := Config(cmd)
@@ -38,10 +48,6 @@ func runGit(cmd *cobra.Command, args []string) {
start := time.Now()
// grab source
source, err := cmd.Flags().GetString("source")
if err != nil {
log.Fatal().Err(err).Msg("could not get source")
}
detector := Detector(cmd, cfg, source)
// set exit code