Skip to content

Commit

Permalink
cmd: fix config flag
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptnull committed Oct 27, 2024
1 parent a530a2f commit 2a45e39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ var rootCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(versionCmd)

serverConfigFilePath = serverCmd.Flags().String("config", "", "Path to the config YAML file")
rootCmd.AddCommand(serverCmd)

rootCmd.AddCommand(scanCmd)
}

Expand Down
11 changes: 4 additions & 7 deletions cmd/server.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"flag"
"log"
"os"
"os/signal"
Expand All @@ -23,18 +22,16 @@ var serverCmd = &cobra.Command{
Run: runServer,
}

var serverConfigFilePath *string

func runServer(cmd *cobra.Command, args []string) {
log.Println("=== Starting goKakashi Tool ===")

// Get config file from command-line argument
configFile := flag.String("config", "", "Path to the config YAML file")
flag.Parse()

if *configFile == "" {
if *serverConfigFilePath == "" {
log.Fatal("Please provide the path to the config YAML file using --config")
}
// Load and validate the configuration file
cfg, err := config.LoadAndValidateConfig(*configFile)
cfg, err := config.LoadAndValidateConfig(*serverConfigFilePath)
if err != nil {
log.Fatalf("Error: %v", err)
}
Expand Down

0 comments on commit 2a45e39

Please sign in to comment.