Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: fix config flag #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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