package main
import (
"fmt"
"os"
"skraak/cmd"
)
func main() {
if len(os.Args) < 2 {
printUsage()
os.Exit(1)
}
switch os.Args[1] {
case "import":
cmd.RunImport(os.Args[2:])
case "sql":
cmd.RunSQL(os.Args[2:])
case "create":
cmd.RunCreate(os.Args[2:])
case "update":
cmd.RunUpdate(os.Args[2:])
case "export":
cmd.RunExport(os.Args[2:])
case "replay":
cmd.RunReplay(os.Args[2:])
case "calls":
cmd.RunCalls(os.Args[2:])
case "xxhash":
cmd.RunXXHash(os.Args[2:])
case "metadata":
cmd.RunMetadata(os.Args[2:])
case "time":
cmd.RunTime(os.Args[2:])
case "isnight":
cmd.RunIsNight(os.Args[2:])
case "prepend":
cmd.RunPrepend(os.Args[2:])
default:
fmt.Fprintf(os.Stderr, "Unknown command: %s\n\n", os.Args[1])
printUsage()
os.Exit(1)
}
}
func printUsage() {
fmt.Fprintf(os.Stderr, "Usage: %s <command> [options]\n\n", os.Args[0])
fmt.Fprintf(os.Stderr, "Commands:\n")
fmt.Fprintf(os.Stderr, " sql Execute SQL query\n")
fmt.Fprintf(os.Stderr, " calls Extract/analyze bird calls (from-preds, from-brida, from-raven, show-images, classify, summarise)\n")
fmt.Fprintf(os.Stderr, " create Create a new resource (dataset, location, cluster, pattern)\n")
fmt.Fprintf(os.Stderr, " update Update an existing resource (dataset, location, cluster, pattern)\n")
fmt.Fprintf(os.Stderr, " import Import data (folder, bulk, unstructured, segments)\n")
fmt.Fprintf(os.Stderr, " export Export dataset to new database\n")
fmt.Fprintf(os.Stderr, " replay Replay event log into database\n")
fmt.Fprintf(os.Stderr, " xxhash Compute XXH64 hash of a file\n")
fmt.Fprintf(os.Stderr, " metadata Extract WAV file metadata\n")
fmt.Fprintf(os.Stderr, " time Get current time\n")
fmt.Fprintf(os.Stderr, " isnight Check if WAV file was recorded at night\n")
fmt.Fprintf(os.Stderr, " prepend Prepend prefix to WAV files and log.txt\n")
fmt.Fprintf(os.Stderr, "\nExamples:\n")
fmt.Fprintf(os.Stderr, " %s sql --db ./db/skraak.duckdb \"SELECT COUNT(*) FROM file WHERE active = true\"\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s create dataset --db ./db/skraak.duckdb --name \"Test Dataset\"\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s update location --db ./db/skraak.duckdb --id loc123 --name \"New Name\"\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s export dataset --db ./db/skraak.duckdb --id abc123 --output export.duckdb\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s replay events --db ./backup.duckdb --log ./skraak.duckdb.events.jsonl\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s calls from-preds --csv predictions.csv > calls.json\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s xxhash --file recording.wav\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s metadata --file recording.wav\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s time\n", os.Args[0])
fmt.Fprintf(os.Stderr, " %s isnight --file recording.wav --lat -36.85 --lng 174.76\n", os.Args[0])
}