diff --git a/init.go b/init.go index 4625fb0..6a079db 100644 --- a/init.go +++ b/init.go @@ -13,10 +13,16 @@ func main() { portFlag := flag.Int("port", 0, "Port number to run the application (overrides config)") domainFlag := flag.String("domain", "", "Domain address for the application (overrides config)") skipConfigFlag := flag.Bool("skip-config-check", false, "Skip interactive prompts and load config.ini") + configFlag := flag.String("config", "", "Path to configuration file (overrides default)") // Parse command-line flags flag.Parse() + // Override global configFilePath if --config flag is provided + if *configFlag != "" { + configFilePath = *configFlag + } + if *skipConfigFlag { // Skip interactive configuration if _, err := os.Stat(configFilePath); err == nil { @@ -136,11 +142,6 @@ func main() { webCrawlerInit() - // No longer needed as crawled data are indexed imidietly - // // Start periodic indexing (every 2 minutes) - // dataFilePath := filepath.Join(config.DriveCache.Path, "data_to_index.txt") - // startPeriodicIndexing(dataFilePath, 2*time.Minute) - printInfo("Indexer is enabled.") } else { printInfo("Indexer is disabled.") diff --git a/run.bat b/run.bat index f57ddcf..dd485f9 100755 --- a/run.bat +++ b/run.bat @@ -5,6 +5,7 @@ rem Initialize variables set SKIP_CONFIG="" set PORT="" set DOMAIN="" +set CONFIG_FILE="" set BUILD_OUTPUT=qgato.exe rem Parse arguments @@ -22,6 +23,12 @@ if "%~1"=="--domain" ( shift goto parse_args ) +if "%~1"=="--config" ( + set CONFIG_FILE=%~2 + shift + shift + goto parse_args +) if "%~1"=="--skip-config-check" ( set SKIP_CONFIG=--skip-config-check shift @@ -60,6 +67,7 @@ rem Construct the command set CMD=%BUILD_OUTPUT% !SKIP_CONFIG! if not "%PORT%"=="" set CMD=!CMD! --port %PORT% if not "%DOMAIN%"=="" set CMD=!CMD! --domain %DOMAIN% +if not "%CONFIG_FILE%"=="" set CMD=!CMD! --config %CONFIG_FILE% rem Informative output echo Starting application with command: !CMD! diff --git a/run.sh b/run.sh index 400ebc9..089e11f 100755 --- a/run.sh +++ b/run.sh @@ -4,6 +4,7 @@ SKIP_CONFIG="" PORT="" DOMAIN="" +CONFIG_FILE="" BUILD_OUTPUT="qgato" # Parse arguments @@ -17,6 +18,10 @@ while [ $# -gt 0 ]; do DOMAIN=$2 shift 2 ;; + --config) + CONFIG_FILE=$2 + shift 2 + ;; --skip-config-check) SKIP_CONFIG="--skip-config-check" shift @@ -51,6 +56,7 @@ fi CMD="$SCRIPT_DIR/$BUILD_OUTPUT $SKIP_CONFIG" [ -n "$PORT" ] && CMD="$CMD --port $PORT" [ -n "$DOMAIN" ] && CMD="$CMD --domain $DOMAIN" +[ -n "$CONFIG_FILE" ] && CMD="$CMD --config $CONFIG_FILE" echo "Starting application with command: $CMD"