package cmd
import (
"fmt"
"os"
)
// RunCreate handles the "create" command
func RunCreate(args []string) {
if len(args) < 1 {
printCreateUsage()
os.Exit(1)
}
switch args[0] {
case "dataset":
RunDatasetCreate(args[1:])
case "location":
RunLocationCreate(args[1:])
case "cluster":
RunClusterCreate(args[1:])
case "pattern":
RunPatternCreate(args[1:])
default:
fmt.Fprintf(os.Stderr, "Unknown resource to create: %s\n", args[0])
printCreateUsage()
os.Exit(1)
}
}
func printCreateUsage() {
fmt.Fprintf(os.Stderr, "Usage: skraak create <resource> [options]\n\n")
fmt.Fprintf(os.Stderr, "Resources:\n")
fmt.Fprintf(os.Stderr, " dataset Create a new dataset\n")
fmt.Fprintf(os.Stderr, " location Create a new location\n")
fmt.Fprintf(os.Stderr, " cluster Create a new cluster\n")
fmt.Fprintf(os.Stderr, " pattern Create a new pattern\n")
fmt.Fprintf(os.Stderr, "\nExamples:\n")
fmt.Fprintf(os.Stderr, " skraak create dataset --db ./db/skraak.duckdb --name \"Test Dataset\"\n")
fmt.Fprintf(os.Stderr, " skraak create location --db ./db/skraak.duckdb --dataset abc123 --name \"Site A\" --lat -36.85 --lon 174.76 --timezone Pacific/Auckland\n")
fmt.Fprintf(os.Stderr, " skraak create cluster --db ./db/skraak.duckdb --dataset abc123 --location loc456 --name \"2024-01\" --sample-rate 250000\n")
fmt.Fprintf(os.Stderr, " skraak create pattern --db ./db/skraak.duckdb --dataset abc123 --name \"Recording Schedule\" --type daily --start-time 18:00 --end-time 06:00\n")
}