49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
sourceDir := flag.String("source", "", "Path to Go source root (e.g., ../../golang/nats-server)")
|
|
dbPath := flag.String("db", "", "Path to SQLite database file (e.g., ../../porting.db)")
|
|
schemaPath := flag.String("schema", "", "Path to SQL schema file (e.g., ../../porting-schema.sql)")
|
|
flag.Parse()
|
|
|
|
if *sourceDir == "" || *dbPath == "" || *schemaPath == "" {
|
|
fmt.Fprintf(os.Stderr, "Usage: go-analyzer --source <path> --db <path> --schema <path>\n")
|
|
flag.PrintDefaults()
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Open DB and apply schema
|
|
db, err := OpenDB(*dbPath, *schemaPath)
|
|
if err != nil {
|
|
log.Fatalf("Failed to open database: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
// Run analysis
|
|
analyzer := NewAnalyzer(*sourceDir)
|
|
result, err := analyzer.Analyze()
|
|
if err != nil {
|
|
log.Fatalf("Analysis failed: %v", err)
|
|
}
|
|
|
|
// Write to DB
|
|
writer := NewDBWriter(db)
|
|
if err := writer.WriteAll(result); err != nil {
|
|
log.Fatalf("Failed to write results: %v", err)
|
|
}
|
|
|
|
fmt.Printf("Analysis complete:\n")
|
|
fmt.Printf(" Modules: %d\n", len(result.Modules))
|
|
fmt.Printf(" Features: %d\n", result.TotalFeatures())
|
|
fmt.Printf(" Unit Tests: %d\n", result.TotalTests())
|
|
fmt.Printf(" Dependencies: %d\n", len(result.Dependencies))
|
|
fmt.Printf(" Imports: %d\n", len(result.Imports))
|
|
}
|